ZQuest Classic Coverage Report


Directory: src/
File: src/zc/script_drawing.cpp
Date: 2025-12-07 03:15:32
Exec Total Coverage
Lines: 1487 5751 25.9%
Functions: 54 108 50.0%
Branches: 635 2962 21.4%

Line Branch Exec Source
1 //! ritate_sprite_trans doesn't seem to be supported by or allegro header !?
2
3 //glibc 2.28 and later require this: -Z
4 #include <optional>
5 #include <utility>
6 #ifdef __GNUG__
7 #define ALLEGRO_NO_FIX_ALIASES
8 #endif
9
10 #include "base/qrs.h"
11 #include "base/dmap.h"
12 #include "base/zdefs.h"
13 #include "base/zc_alleg.h"
14 #include "zc/script_drawing.h"
15 #include "zc/rendertarget.h"
16 #include "zc/maps.h"
17 #include "tiles.h"
18 #include "zc/zelda.h"
19 #include "zc/ffscript.h"
20 #include "base/util.h"
21 #include "subscr.h"
22 #include "drawing.h"
23 #include "base/mapscr.h"
24 #include "base/misctypes.h"
25 using namespace util;
26 extern refInfo *ri;
27 extern script_bitmaps scb;
28 #include <stdio.h>
29 #include <fstream>
30
31 static int32_t secondary_draw_origin_xoff;
32 static int32_t secondary_draw_origin_yoff;
33
34 124968468 static std::optional<std::pair<int, int>> get_draw_origin_offset(DrawOrigin draw_origin, int draw_origin_target_uid, int xoff, int yoff)
35 {
36 int xoffset;
37 int yoffset;
38
2/2
✓ Branch 0 taken 41428 times.
✓ Branch 1 taken 124927040 times.
124968468 if (draw_origin == DrawOrigin::Region)
39 {
40 41428 xoffset = xoff - viewport.x;
41 41428 yoffset = yoff - viewport.y;
42 41428 }
43
2/2
✓ Branch 0 taken 8072 times.
✓ Branch 1 taken 124918968 times.
124927040 else if (draw_origin == DrawOrigin::RegionScrollingNew)
44 {
45 8072 xoffset = xoff + FFCore.ScrollingData[SCROLLDATA_NRX];
46 8072 yoffset = yoff + FFCore.ScrollingData[SCROLLDATA_NRY];
47 8072 }
48
2/2
✓ Branch 0 taken 105315950 times.
✓ Branch 1 taken 19603018 times.
124918968 else if (draw_origin == DrawOrigin::PlayingField)
49 {
50 105315950 xoffset = xoff;
51 105315950 yoffset = yoff;
52 105315950 }
53
2/2
✓ Branch 0 taken 19596907 times.
✓ Branch 1 taken 6111 times.
19603018 else if (draw_origin == DrawOrigin::Screen)
54 {
55 19596907 xoffset = 0;
56 19596907 yoffset = 0;
57 19596907 }
58
1/2
✓ Branch 0 taken 6111 times.
✗ Branch 1 not taken.
6111 else if (draw_origin == DrawOrigin::Sprite)
59 {
60 6111 sprite* draw_origin_target = sprite::getByUID(draw_origin_target_uid);
61
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6111 times.
6111 if (!draw_origin_target)
62 {
63 Z_scripterrlog("Warning: Ignoring draw command using DRAW_ORIGIN_SPRITE with non-existent sprite uid: %d.\n", draw_origin_target_uid);
64 return std::nullopt;
65 }
66
67 6111 xoffset = xoff - viewport.x + draw_origin_target->x.getInt();
68 6111 yoffset = yoff - viewport.y + draw_origin_target->y.getInt();
69 6111 }
70 else
71 {
72 // Unexpected.
73 xoffset = 0;
74 yoffset = 0;
75 }
76
77 124968468 return std::make_pair(xoffset, yoffset);
78 124968468 }
79
80 23279041 std::pair<int, bool> resolveScriptingBitmapId(int scripting_bitmap_id)
81 {
82
4/6
✓ Branch 0 taken 3396548 times.
✓ Branch 1 taken 19882493 times.
✓ Branch 2 taken 3396548 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 3396548 times.
✗ Branch 5 not taken.
23279041 if ((scripting_bitmap_id % 10000 == 0) && (scripting_bitmap_id >= -20000 && scripting_bitmap_id <= 60000))
83 {
84 // Handles zscript values for RT_SCREEN, RT_BITMAP0, etc.
85 3396548 return {scripting_bitmap_id / 10000, false};
86 }
87
3/4
✓ Branch 0 taken 19882493 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11739102 times.
✓ Branch 3 taken 8143391 times.
19882493 else if (scripting_bitmap_id - 10 >= -2 && scripting_bitmap_id - 10 <= rtBMP6)
88 {
89 // Handles Game->LoadBitmapID, which sets the bitmap pointer as a "long" int.
90 8143391 return {scripting_bitmap_id - 10, false};
91 }
92 else
93 {
94 // This is a user bitmap.
95 11739102 return {scripting_bitmap_id, true};
96 }
97 23279041 }
98
99 static BITMAP* current_target_bmp;
100
101 66997310 static BITMAP* resolveScriptingBitmap(int scripting_bitmap_id)
102 {
103
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 66997310 times.
66997310 if (scripting_bitmap_id < 0)
104 {
105 // Handles zscript values for RT_SCREEN, etc.
106 return FFCore.GetScriptBitmap((scripting_bitmap_id / 10000) + 10, current_target_bmp);
107 }
108 else
109 {
110 // Handles Game->LoadBitmapID, which sets the bitmap pointer as a "long" int.
111 // Also handles user bitmaps.
112 66997310 return FFCore.GetScriptBitmap(scripting_bitmap_id, current_target_bmp);
113 }
114 66997310 }
115
116 inline double sd_log2( double n )
117 {
118 // log(n)/log(2) is log2.
119 double v = log( (double)n ) / log( (double)2 );
120 return v;
121 }
122
123 inline bool isPowerOfTwo(int32_t n)
124 {
125 if(n==0)
126 return false;
127
128 return (ceil(sd_log2(n)) == floor(sd_log2(n)));
129 }
130
131 BITMAP* ScriptDrawingBitmapPool::_parent_bmp = 0;
132
133 class TileHelper
134 {
135 public:
136
137 46094 static void OldPutTile(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, byte skiprows=0)
138 {
139 // Past the end of the tile page?
140
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 46094 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
46094 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
141 {
142 byte w2=(tile+w)%TILES_PER_ROW;
143 OldPutTile(_Dest, tile, x, y, w-w2, h, color, flip);
144 OldPutTile(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip);
145 return;
146 }
147
148
1/5
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 46094 times.
46094 switch(flip)
149 {
150 case 1:
151 for(int32_t j=0; j<h; j++)
152 for(int32_t k=w-1; k>=0; k--)
153 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip);
154
155 break;
156
157 case 2:
158 for(int32_t j=h-1; j>=0; j--)
159 for(int32_t k=0; k<w; k++)
160 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip);
161
162 break;
163
164 case 3:
165 for(int32_t j=h-1; j>=0; j--)
166 for(int32_t k=w-1; k>=0; k--)
167 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip);
168
169 break;
170
171 46094 case 0:
172 default:
173
2/2
✓ Branch 0 taken 181240 times.
✓ Branch 1 taken 46094 times.
227334 for(int32_t j=0; j<h; j++)
174
2/2
✓ Branch 0 taken 1111148 times.
✓ Branch 1 taken 181240 times.
1292388 for(int32_t k=0; k<w; k++)
175 1292388 oldputtile16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip);
176
177 46094 break;
178 }
179 46094 }
180
181 4793800 static void OverTile(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, byte skiprows=0)
182 {
183 4793800 overtileblock16(_Dest,tile,x,y,w,h,color,flip,skiprows);
184 4793800 }
185
186 static void OverTileCloaked(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t flip, byte skiprows=0)
187 {
188 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
189 {
190 byte w2=(tile+w)%TILES_PER_ROW;
191 OverTileCloaked(_Dest, tile, x, y, w-w2, h, flip);
192 OverTileCloaked(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, flip);
193 return;
194 }
195
196 switch(flip)
197 {
198 case 1:
199 for(int32_t j=0; j<h; j++)
200 for(int32_t k=w-1; k>=0; k--)
201 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, flip);
202
203 break;
204
205 case 2:
206 for(int32_t j=h-1; j>=0; j--)
207 for(int32_t k=0; k<w; k++)
208 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, flip);
209
210 break;
211
212 case 3:
213 for(int32_t j=h-1; j>=0; j--)
214 for(int32_t k=w-1; k>=0; k--)
215 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, flip);
216
217 break;
218
219 default:
220 for(int32_t j=0; j<h; j++)
221 for(int32_t k=0; k<w; k++)
222 overtilecloaked16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, flip);
223
224 break;
225 }
226 }
227
228 289390 static void OverTileTranslucent(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, int32_t opacity, byte skiprows=0)
229 {
230
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 289390 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
289390 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
231 {
232 byte w2=(tile+w)%TILES_PER_ROW;
233 OverTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity);
234 OverTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity);
235 return;
236 }
237
238
1/4
✓ Branch 0 taken 289390 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
289390 switch(flip)
239 {
240 case 1:
241 for(int32_t j=0; j<h; j++)
242 for(int32_t k=w-1; k>=0; k--)
243 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity);
244
245 break;
246
247 case 2:
248 for(int32_t j=h-1; j>=0; j--)
249 for(int32_t k=0; k<w; k++)
250 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity);
251
252 break;
253
254 case 3:
255 for(int32_t j=h-1; j>=0; j--)
256 for(int32_t k=w-1; k>=0; k--)
257 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity);
258
259 break;
260
261 default:
262
2/2
✓ Branch 0 taken 1672950 times.
✓ Branch 1 taken 289390 times.
1962340 for(int32_t j=0; j<h; j++)
263
2/2
✓ Branch 0 taken 23552575 times.
✓ Branch 1 taken 1672950 times.
25225525 for(int32_t k=0; k<w; k++)
264 25225525 overtiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity);
265
266 289390 break;
267 }
268 289390 }
269
270 static void PutTileTranslucent(BITMAP* _Dest, int32_t tile, int32_t x, int32_t y, int32_t w, int32_t h, int32_t color, int32_t flip, int32_t opacity, byte skiprows=0)
271 {
272 if(skiprows>0 && tile%TILES_PER_ROW+w>=TILES_PER_ROW)
273 {
274 byte w2=(tile+w)%TILES_PER_ROW;
275 PutTileTranslucent(_Dest, tile, x, y, w-w2, h, color, flip, opacity);
276 PutTileTranslucent(_Dest, tile+(w-w2)+(skiprows*TILES_PER_ROW), x+16*(w-w2), y, w2, h, color, flip, opacity);
277 return;
278 }
279
280 switch(flip)
281 {
282 case 1:
283 for(int32_t j=0; j<h; j++)
284 for(int32_t k=w-1; k>=0; k--)
285 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+j*16, color, flip, opacity);
286
287 break;
288
289 case 2:
290 for(int32_t j=h-1; j>=0; j--)
291 for(int32_t k=0; k<w; k++)
292 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+((h-1)-j)*16, color, flip, opacity);
293
294 break;
295
296 case 3:
297 for(int32_t j=h-1; j>=0; j--)
298 for(int32_t k=w-1; k>=0; k--)
299 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+((w-1)-k)*16, y+((h-1)-j)*16, color, flip, opacity);
300
301 break;
302
303 default:
304 for(int32_t j=0; j<h; j++)
305 for(int32_t k=0; k<w; k++)
306 puttiletranslucent16(_Dest, tile+(j*TILES_PER_ROW)+k, x+k*16, y+j*16, color, flip, opacity);
307
308 break;
309 }
310 }
311 };
312
313
314
315
316 3344855 void do_rectr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
317 {
318 //sdci[1]=layer
319 //sdci[2]=x
320 //sdci[3]=y
321 //sdci[4]=x2
322 //sdci[5]=y2
323 //sdci[6]=color
324 //sdci[7]=scale factor
325 //sdci[8]=rotation anchor x
326 //sdci[9]=rotation anchor y
327 //sdci[10]=rotation angle
328 //sdci[11]=fill
329 //sdci[12]=opacity
330
1/2
✓ Branch 0 taken 3344855 times.
✗ Branch 1 not taken.
3344855 if(sdci[7]==0) //scale
331 {
332 return;
333 }
334
335 3344855 int32_t x1=sdci[2]/10000;
336 3344855 int32_t y1=sdci[3]/10000;
337 3344855 int32_t x2=sdci[4]/10000;
338 3344855 int32_t y2=sdci[5]/10000;
339
340
1/2
✓ Branch 0 taken 3344855 times.
✗ Branch 1 not taken.
3344855 if(x1>x2)
341 {
342 zc_swap(x1,x2);
343 }
344
345
2/2
✓ Branch 0 taken 3325339 times.
✓ Branch 1 taken 19516 times.
3344855 if(y1>y2)
346 {
347 19516 zc_swap(y1,y2);
348 19516 }
349
350
2/2
✓ Branch 0 taken 3342035 times.
✓ Branch 1 taken 2820 times.
3344855 if(sdci[7] != 10000)
351 {
352 2820 int32_t w=x2-x1+1;
353 2820 int32_t h=y2-y1+1;
354 2820 int32_t w2=(w*sdci[7])/10000;
355 2820 int32_t h2=(h*sdci[7])/10000;
356 2820 x1=x1-((w2-w)/2);
357 2820 x2=x2+((w2-w)/2);
358 2820 y1=y1-((h2-h)/2);
359 2820 y2=y2+((h2-h)/2);
360 2820 }
361
362 3344855 int32_t color=sdci[6]/10000;
363
364
2/2
✓ Branch 0 taken 3308009 times.
✓ Branch 1 taken 36846 times.
3344855 if(sdci[12]/10000<=127) //translucent
365 {
366 36846 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
367 36846 }
368
369
2/2
✓ Branch 0 taken 82060 times.
✓ Branch 1 taken 3262795 times.
3344855 if(sdci[10]==0) //no rotation
370 {
371
2/2
✓ Branch 0 taken 838727 times.
✓ Branch 1 taken 2424068 times.
3262795 if(sdci[11]) //filled
372 {
373 2424068 rectfill(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
374 2424068 }
375 else //outline
376 {
377 838727 rect(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
378 }
379 3262795 }
380 else //rotate
381 {
382 int32_t xy[16];
383 82060 int32_t rx=sdci[8]/10000;
384 82060 int32_t ry=sdci[9]/10000;
385 82060 fixed ra1=itofix(sdci[10]%10000)/10000;
386 82060 fixed ra2=itofix(sdci[10]/10000);
387 82060 fixed ra=ra1+ra2;
388 82060 ra = (ra/360)*256;
389
390 82060 fixed fcosa = fixcos(ra);
391 82060 fixed fsina = fixsin(ra);
392
393 82060 xy[ 0]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry))); //x1
394 82060 xy[ 1]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry))); //y1
395 82060 xy[ 2]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y1 - ry))); //x2
396 82060 xy[ 3]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y1 - ry))); //y1
397 82060 xy[ 4]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry))); //x2
398 82060 xy[ 5]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry))); //y2
399 82060 xy[ 6]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y2 - ry))); //x1
400 82060 xy[ 7]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y2 - ry))); //y2
401 82060 xy[ 8]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry + 1))); //x1
402 82060 xy[ 9]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry + 1))); //y1
403 82060 xy[10]=xoffset+rx + fixtoi((fcosa * (x2 - rx - 1) - fsina * (y1 - ry))); //x2
404 82060 xy[11]=yoffset+ry + fixtoi((fsina * (x2 - rx - 1) + fcosa * (y1 - ry))); //y1
405 82060 xy[12]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry - 1))); //x2
406 82060 xy[13]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry - 1))); //y2
407 82060 xy[14]=xoffset+rx + fixtoi((fcosa * (x1 - rx + 1) - fsina * (y2 - ry))); //x1
408 82060 xy[15]=yoffset+ry + fixtoi((fsina * (x1 - rx + 1) + fcosa * (y2 - ry))); //y2
409
410
1/2
✓ Branch 0 taken 82060 times.
✗ Branch 1 not taken.
82060 if(sdci[11]) //filled
411 {
412 82060 polygon(bmp, 4, xy, color);
413 82060 }
414 else //outline
415 {
416 line(bmp, xy[0], xy[1], xy[10], xy[11], color);
417 line(bmp, xy[2], xy[3], xy[12], xy[13], color);
418 line(bmp, xy[4], xy[5], xy[14], xy[15], color);
419 line(bmp, xy[6], xy[7], xy[ 8], xy[ 9], color);
420 }
421 }
422
423 3344855 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
424 3344855 }
425
426 void do_framer(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
427 {
428 //sdci[1]=layer
429 //sdci[2]=x
430 //sdci[3]=y
431 //sdci[4]=tile
432 //sdci[5]=cset
433 //sdci[6]=width
434 //sdci[7]=height
435 //sdci[8]=overlay
436 //sdci[9]=opacity
437
438 int32_t x=sdci[2]/10000;
439 int32_t y=sdci[3]/10000;
440
441 int32_t tile=sdci[4]/10000;
442 int32_t cs=sdci[5]/10000;
443 int32_t w=sdci[6]/10000;
444 int32_t h=sdci[7]/10000;
445 bool overlay=sdci[8];
446 bool trans=(sdci[9]/10000<=127);
447
448 frame2x2(bmp, x + xoffset, y + yoffset, tile, cs, w, h, 0, overlay, trans);
449 }
450
451
452
453 1170681 void do_circler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
454 {
455 //sdci[1]=layer
456 //sdci[2]=x
457 //sdci[3]=y
458 //sdci[4]=radius
459 //sdci[5]=color
460 //sdci[6]=scale factor
461 //sdci[7]=rotation anchor x
462 //sdci[8]=rotation anchor y
463 //sdci[9]=rotation angle
464 //sdci[10]=fill
465 //sdci[11]=opacity
466
1/2
✓ Branch 0 taken 1170681 times.
✗ Branch 1 not taken.
1170681 if(sdci[6]==0) //scale
467 {
468 return;
469 }
470
471 1170681 int32_t x1=sdci[2]/10000;
472 1170681 int32_t y1=sdci[3]/10000;
473 1170681 qword r=sdci[4];
474
475
1/2
✓ Branch 0 taken 1170681 times.
✗ Branch 1 not taken.
1170681 if(sdci[6] != 10000)
476 {
477 r*=sdci[6];
478 r/=10000;
479 }
480
481 1170681 r/=10000;
482 1170681 int32_t color=sdci[5]/10000;
483
484
2/2
✓ Branch 0 taken 989374 times.
✓ Branch 1 taken 181307 times.
1170681 if(sdci[11]/10000<=127) //translucent
485 {
486 181307 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
487 181307 }
488
489
5/6
✓ Branch 0 taken 58575 times.
✓ Branch 1 taken 1112106 times.
✓ Branch 2 taken 1344 times.
✓ Branch 3 taken 57231 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1344 times.
1170681 if(sdci[9]!=0&&(sdci[2]!=sdci[7]||sdci[3]!=sdci[8])) //rotation
490 {
491 int32_t xy[2];
492 57231 int32_t rx=sdci[7]/10000;
493 57231 int32_t ry=sdci[8]/10000;
494 57231 fixed ra1=itofix(sdci[9]%10000)/10000;
495 57231 fixed ra2=itofix(sdci[9]/10000);
496 57231 fixed ra=ra1+ra2;
497 57231 ra = (ra/360)*256;
498
499 57231 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
500 57231 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
501 57231 x1=xy[0];
502 57231 y1=xy[1];
503 57231 }
504
505
2/2
✓ Branch 0 taken 1153667 times.
✓ Branch 1 taken 17014 times.
1170681 if(sdci[10]) //filled
506 {
507 1153667 circlefill(bmp, x1+xoffset, y1+yoffset, r, color);
508 1153667 }
509 else //outline
510 {
511 17014 circle(bmp, x1+xoffset, y1+yoffset, r, color);
512 }
513
514 1170681 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
515 1170681 }
516
517
518 void do_arcr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
519 {
520 //sdci[1]=layer
521 //sdci[2]=x
522 //sdci[3]=y
523 //sdci[4]=radius
524 //sdci[5]=start angle
525 //sdci[6]=end angle
526 //sdci[7]=color
527 //sdci[8]=scale factor
528 //sdci[9]=rotation anchor x
529 //sdci[10]=rotation anchor y
530 //sdci[11]=rotation angle
531 //sdci[12]=closed
532 //sdci[13]=fill
533 //sdci[14]=opacity
534
535 if(sdci[8]==0) //scale
536 {
537 return;
538 }
539
540 int32_t cx=sdci[2]/10000;
541 int32_t cy=sdci[3]/10000;
542 qword r=sdci[4];
543
544 if(sdci[8] != 10000)
545 {
546 r*=sdci[8];
547 r/=10000;
548 }
549
550 r/=10000;
551
552 int32_t color=sdci[7]/10000;
553
554 fixed ra1=itofix(sdci[11]%10000)/10000;
555 fixed ra2=itofix(sdci[11]/10000);
556 fixed ra=ra1+ra2;
557 ra = (ra/360)*256;
558
559
560 fixed a1=itofix(sdci[5]%10000)/10000;
561 fixed a2=itofix(sdci[5]/10000);
562 fixed sa=a1+a2;
563 sa = (sa/360)*256;
564
565 a1=itofix(sdci[6]%10000)/10000;
566 a2=itofix(sdci[6]/10000);
567 fixed ea=a1+a2;
568 ea = (ea/360)*256;
569
570 if(sdci[11]!=0) //rotation
571 {
572 int32_t rx=sdci[9]/10000;
573 int32_t ry=sdci[10]/10000;
574
575 cx=rx + fixtoi((fixcos(ra) * (cx - rx) - fixsin(ra) * (cy - ry))); //x1
576 cy=ry + fixtoi((fixsin(ra) * (cx - rx) + fixcos(ra) * (cy - ry))); //y1
577 ea-=ra;
578 sa-=ra;
579 }
580
581 int32_t fx=cx+fixtoi(fixcos(-(ea+sa)/2)*r/2);
582 int32_t fy=cy+fixtoi(fixsin(-(ea+sa)/2)*r/2);
583
584 if(sdci[12]) //closed
585 {
586 if(sdci[13]) //filled
587 {
588 clear_bitmap(prim_bmp);
589 arc(prim_bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
590 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
591 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
592 int fillx = zc_max(0,fx)+xoffset;
593 int filly = zc_max(0,fy)+yoffset;
594 zprint2("Screen->Arc fill at prim_bmp (%d,%d) - 512x512\n", fillx, filly);
595 floodfill(prim_bmp, fillx, filly, color);
596
597 if(sdci[14]/10000<=127) //translucent
598 {
599 draw_trans_sprite(bmp, prim_bmp, 0,0);
600 }
601 else
602 {
603 draw_sprite(bmp, prim_bmp, 0,0);
604 }
605 }
606 else
607 {
608 arc(bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
609 line(bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
610 line(bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
611 }
612 }
613 else
614 {
615 if(sdci[14]/10000<=127) //translucent
616 {
617 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
618 }
619
620 arc(bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
621 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
622 }
623 }
624
625
626 1850 void do_ellipser(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
627 {
628 //sdci[1]=layer
629 //sdci[2]=x
630 //sdci[3]=y
631 //sdci[4]=radiusx
632 //sdci[5]=radiusy
633 //sdci[6]=color
634 //sdci[7]=scale factor
635 //sdci[8]=rotation anchor x
636 //sdci[9]=rotation anchor y
637 //sdci[10]=rotation angle
638 //sdci[11]=fill
639 //sdci[12]=opacity
640
641
1/2
✓ Branch 0 taken 1850 times.
✗ Branch 1 not taken.
1850 if(sdci[7]==0) //scale
642 {
643 return;
644 }
645
646 1850 int32_t x1=sdci[2]/10000;
647 1850 int32_t y1=sdci[3]/10000;
648 1850 int32_t radx=sdci[4]/10000;
649 1850 radx*=sdci[7]/10000;
650 1850 int32_t rady=sdci[5]/10000;
651 1850 rady*=sdci[7]/10000;
652 1850 int32_t color=sdci[6]/10000;
653 1850 float rotation = sdci[10]/10000;
654
655 1850 int32_t rx=sdci[8]/10000;
656 1850 int32_t ry=sdci[9]/10000;
657 1850 fixed ra1=itofix(sdci[10]%10000)/10000;
658 1850 fixed ra2=itofix(sdci[10]/10000);
659 1850 fixed ra=ra1+ra2;
660 1850 ra = (ra/360)*256;
661
662 int32_t xy[2];
663 1850 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
664 1850 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
665 1850 x1=xy[0];
666 1850 y1=xy[1];
667
668
6/8
✓ Branch 0 taken 1746 times.
✓ Branch 1 taken 104 times.
✓ Branch 2 taken 1687 times.
✓ Branch 3 taken 59 times.
✓ Branch 4 taken 1687 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 1687 times.
1850 if(radx<1||rady<1||radx>255||rady>255) return;
669
670 1687 BITMAP* bitty = script_drawing_commands.AquireSubBitmap(radx*2+1, rady*2+1);
671
672
2/2
✓ Branch 0 taken 1630 times.
✓ Branch 1 taken 57 times.
1687 if(sdci[11]) //filled
673 {
674
675
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 606 times.
1630 if(sdci[12]/10000<128) //translucent
676 {
677 1024 clear_bitmap(prim_bmp);
678
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
679 1024 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
680 1024 draw_trans_sprite(bmp, prim_bmp, 0, 0);
681 1024 }
682 else // no opacity
683 {
684
1/2
✓ Branch 0 taken 606 times.
✗ Branch 1 not taken.
606 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
685 606 rotate_sprite(bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
686 }
687 1630 }
688 else //not filled
689 {
690
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 43 times.
57 if(sdci[12]/10000<128) //translucent
691 {
692 14 clear_bitmap(prim_bmp);
693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 14 times.
14 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
694 14 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
695 14 draw_trans_sprite(bmp, prim_bmp, 0, 0);
696 14 }
697 else // no opacity
698 {
699
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43 times.
43 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
700 43 rotate_sprite(bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
701 }
702 }
703
704 // Since 0 is the transparent color, the stuff above will fail if the ellipse color is also 0.
705 // Instead, it uses color 255 and replaces it afterward. That'll also screw up color 255 around
706 // the ellipse, but it shouldn't be used anyway.
707
1/2
✓ Branch 0 taken 1687 times.
✗ Branch 1 not taken.
1687 if(color==0)
708 {
709 // This is very slow, so check the smallest possible square
710 int32_t endx=zc_min(bmp->w-1, x1+zc_max(radx, rady));
711 int32_t endy=zc_min(bmp->h-1, y1+zc_max(radx, rady));
712
713 for(int32_t y=zc_max(0, y1-zc_max(radx, rady)); y<=endy; y++)
714 for(int32_t x=zc_max(0, x1-zc_max(radx, rady)); x<=endx; x++)
715 if(getpixel(bmp, x, y)==255)
716 putpixel(bmp, x, y, 0);
717 }
718
719 1687 script_drawing_commands.ReleaseSubBitmap(bitty);
720 1850 }
721
722
723 2351475 void do_liner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
724 {
725 //sdci[1]=layer
726 //sdci[2]=x
727 //sdci[3]=y
728 //sdci[4]=x2
729 //sdci[5]=y2
730 //sdci[6]=color
731 //sdci[7]=scale factor
732 //sdci[8]=rotation anchor x
733 //sdci[9]=rotation anchor y
734 //sdci[10]=rotation angle
735 //sdci[11]=opacity
736
1/2
✓ Branch 0 taken 2351475 times.
✗ Branch 1 not taken.
2351475 if(sdci[7]==0) //scale
737 {
738 return;
739 }
740
741 2351475 int32_t x1=sdci[2]/10000;
742 2351475 int32_t y1=sdci[3]/10000;
743 2351475 int32_t x2=sdci[4]/10000;
744 2351475 int32_t y2=sdci[5]/10000;
745
746
2/2
✓ Branch 0 taken 1903153 times.
✓ Branch 1 taken 448322 times.
2351475 if(sdci[7] != 10000)
747 {
748 448322 int32_t w=x2-x1+1;
749 448322 int32_t h=y2-y1+1;
750 448322 int32_t w2=int32_t(w*((double)sdci[7]/10000.0));
751 448322 int32_t h2=int32_t(h*((double)sdci[7]/10000.0));
752 448322 x1=x1-((w2-w)/2);
753 448322 x2=x2+((w2-w)/2);
754 448322 y1=y1-((h2-h)/2);
755 448322 y2=y2+((h2-h)/2);
756 448322 }
757
758 2351475 int32_t color=sdci[6]/10000;
759
760
1/2
✓ Branch 0 taken 2351475 times.
✗ Branch 1 not taken.
2351475 if(sdci[11]/10000<=127) //translucent
761 {
762 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
763 }
764
765
2/2
✓ Branch 0 taken 939459 times.
✓ Branch 1 taken 1412016 times.
2351475 if(sdci[10]!=0) //rotation
766 {
767 int32_t xy[4];
768 1412016 int32_t rx=sdci[8]/10000;
769 1412016 int32_t ry=sdci[9]/10000;
770 1412016 fixed ra1=itofix(sdci[10]%10000)/10000;
771 1412016 fixed ra2=itofix(sdci[10]/10000);
772 1412016 fixed ra=ra1+ra2;
773
774 1412016 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
775 1412016 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
776 1412016 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
777 1412016 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
778 1412016 x1=xy[0];
779 1412016 y1=xy[1];
780 1412016 x2=xy[2];
781 1412016 y2=xy[3];
782 1412016 }
783
784 2351475 line(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
785 2351475 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
786 2351475 }
787
788 void do_linesr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
789 {
790 //sdci[1]=layer
791 //sdci[2]=array[10] = { x, y, x2, y2, colour, scale, rx, ry, angle, opacity }
792
793 //sdci[2]=x
794 //sdci[3]=y
795 //sdci[4]=x2
796 //sdci[5]=y2
797 //sdci[6]=color
798 //sdci[7]=scale factor
799 //sdci[8]=rotation anchor x
800 //sdci[9]=rotation anchor y
801 //sdci[10]=rotation angle
802 //sdci[11]=opacity
803 //if(sdci[7]==0) //scale
804 //{
805 // return;
806 //}
807
808 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
809
810 if(!v_ptr)
811 {
812 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
813 return;
814 }
815
816 std::vector<int32_t> &v = *v_ptr;
817
818 if(v.empty())
819 return;
820
821 int32_t* pos = &v[0];
822 int32_t sz = v.size();
823
824 for ( int32_t q = 0; q < sz; q+=10 )
825 {
826
827 int32_t x1 = v.at(q);
828 //Z_scripterrlog("Lines( x1 ) is: %d\n", x1);
829 int32_t y1 = v.at(q+1);
830 //Z_scripterrlog("Lines( x2 ) is: %d\n", y1);
831 int32_t x2 = v.at(q+2);
832 //Z_scripterrlog("Lines( x2 ) is: %d\n", x2);
833 int32_t y2 = v.at(q+3);
834 //Z_scripterrlog("Lines( y2 ) is: %d\n", y2);
835 int32_t color = v.at(q+4);
836 //Z_scripterrlog("Lines( colour ) is: %d\n", color);
837 //Z_scripterrlog("Lines( scale ) is: %d\n", v.at(q+5));
838 if (v.at(q+5) == 0) { Z_scripterrlog("Lines() aborting due to scale\n"); return; }//scale
839
840 if( v.at(q+5) != 10000)
841 {
842 int32_t w=x2-x1+1;
843 int32_t h=y2-y1+1;
844 int32_t w2=int32_t(w*((double)v.at(q+5)));
845 int32_t h2=int32_t(h*((double)v.at(q+5)));
846 x1=x1-((w2-w)/2);
847 x2=x2+((w2-w)/2);
848 y1=y1-((h2-h)/2);
849 y2=y2+((h2-h)/2);
850 }
851
852
853 //Z_scripterrlog("Lines( opacity ) is: %d\n", v.at(q+9));
854 if(v.at(q+9) <= 127) //translucent
855 {
856 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
857 }
858 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
859 //Z_scripterrlog("Lines( rotation ) is: %d\n", v.at(q+8));
860 //Z_scripterrlog("Lines( rot_x ) is: %d\n", v.at(q+6));
861 //Z_scripterrlog("Lines( rot_x ) is: %d\n", v.at(q+7));
862 if( v.at(q+8) !=0 ) //rotation
863 {
864 int32_t xy[4];
865
866 int32_t rx = v.at(q+6);
867
868 int32_t ry = v.at(q+7);
869
870 fixed ra1=itofix(v.at(q+8) % 1);
871 fixed ra2=itofix(v.at(q+8));
872 fixed ra=ra1+ra2;
873
874 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
875 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
876 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
877 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
878 x1=xy[0];
879 y1=xy[1];
880 x2=xy[2];
881 y2=xy[3];
882 }
883 //Z_scripterrlog("Lines( xofs ) is: %d\n", xoffset);
884 //Z_scripterrlog("Lines( yofs ) is: %d\n", yoffset);
885 line(bmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
886 }
887 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
888 }
889
890 1080 void do_polygonr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
891 {
892 //sdci[1]=layer
893 //sdci[2]=point count
894 //sdci[3]array[]
895 //sdci[4] = colour
896 //sdci[5] = opacity
897
898 1080 int32_t col = sdci[4]/10000;
899 1080 int32_t op = sdci[5]/10000;
900
901 1080 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
902
903
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(!v_ptr)
904 {
905 al_trace("Screen->Polygon: Vector pointer is null! Internal error. \n");
906 return;
907 }
908
909 1080 std::vector<int32_t> &v = *v_ptr;
910
911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1080 times.
1080 if(v.empty())
912 return;
913
914 1080 int32_t* pos = &v[0];
915 1080 int32_t sz = v.size();
916 1080 int32_t numpoints = (sdci[2]/10000);
917
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(sz & 1) --sz; //even amount only
918
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(numpoints > sz/2) //cap to array
919 numpoints = sz/2;
920
1/2
✓ Branch 0 taken 1080 times.
✗ Branch 1 not taken.
1080 if(numpoints < 1)
921 return; //Don't draw 0 or negative point count
922
923
2/2
✓ Branch 0 taken 6480 times.
✓ Branch 1 taken 1080 times.
7560 for (int32_t i = 0; i < sz; i += 2)
924 {
925 6480 pos[i] += xoffset;
926 6480 pos[i + 1] += yoffset;
927 6480 }
928
929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1080 times.
1080 if(op <= 127) //translucent
930 {
931 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
932 }
933 1080 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
934
935 1080 polygon(bmp, numpoints, (int32_t*)pos, col);
936 1080 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
937 1080 }
938
939 void bmp_do_polygonr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
940 {
941 //sdci[1]=layer
942 //sdci[2]=point count
943 //sdci[3]array[]
944 //sdci[4] = colour
945 //sdci[5] = opacity
946
947 int32_t col = sdci[4]/10000;
948 int32_t op = sdci[5]/10000;
949
950 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
951 {
952 Z_scripterrlog("bitmap->Polygon() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
953 return;
954 }
955 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
956 if ( refbmp == NULL ) return;
957
958 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
959
960 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
961
962 if(!v_ptr)
963 {
964 al_trace("bitmap->Polygon: Vector pointer is null! Internal error. \n");
965 return;
966 }
967
968 std::vector<int32_t> &v = *v_ptr;
969
970 if(v.empty())
971 return;
972
973 int32_t* pos = &v[0];
974 int32_t sz = v.size();
975 int32_t numpoints = (sdci[2]/10000);
976 if(sz & 1) --sz; //even amount only
977 if(numpoints > sz/2) //cap to array
978 numpoints = sz/2;
979 if(numpoints < 1)
980 return; //Don't draw 0 or negative point count
981
982 for (int32_t i = 0; i < sz; i += 2)
983 {
984 pos[i] += xoffset;
985 pos[i + 1] += yoffset;
986 }
987
988 if(op <= 127) //translucent
989 {
990 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
991 }
992 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
993
994 polygon(refbmp, numpoints, (int32_t*)pos, col);
995 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
996 }
997
998 void do_spliner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
999 {
1000 /* layer, x1, y1, x2, y2, x3, y3, x4, y4, color, opacity */
1001
1002 int32_t points[8] = { xoffset + (sdci[2]/10000), yoffset + (sdci[3]/10000),
1003 xoffset + (sdci[4]/10000), yoffset + (sdci[5]/10000),
1004 xoffset + (sdci[6]/10000), yoffset + (sdci[7]/10000),
1005 xoffset + (sdci[8]/10000), yoffset + (sdci[9]/10000)
1006 };
1007
1008 if(sdci[11]/10000 < 128) //translucent
1009 {
1010 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1011 }
1012
1013 spline(bmp, points, sdci[10]/10000);
1014
1015 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1016 }
1017
1018
1019 404879 void do_putpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1020 {
1021 //sdci[1]=layer
1022 //sdci[2]=x
1023 //sdci[3]=y
1024 //sdci[4]=color
1025 //sdci[5]=rotation anchor x
1026 //sdci[6]=rotation anchor y
1027 //sdci[7]=rotation angle
1028 //sdci[8]=opacity
1029 404879 int32_t x1=sdci[2]/10000;
1030 404879 int32_t y1=sdci[3]/10000;
1031 404879 int32_t color=sdci[4]/10000;
1032
1033
2/2
✓ Branch 0 taken 404863 times.
✓ Branch 1 taken 16 times.
404879 if(sdci[8]/10000<=127) //translucent
1034 {
1035 16 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1036 16 }
1037
1038
1/2
✓ Branch 0 taken 404879 times.
✗ Branch 1 not taken.
404879 if(sdci[7]!=0) //rotation
1039 {
1040 int32_t xy[2];
1041 int32_t rx=sdci[5]/10000;
1042 int32_t ry=sdci[6]/10000;
1043 fixed ra1=itofix(sdci[7]%10000)/10000;
1044 fixed ra2=itofix(sdci[7]/10000);
1045 fixed ra=ra1+ra2;
1046
1047 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1048 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1049 x1=xy[0];
1050 y1=xy[1];
1051 }
1052
1053 404879 putpixel(bmp, x1+xoffset, y1+yoffset, color);
1054 404879 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1055 404879 }
1056
1057 void do_putpixelsr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1058 {
1059 //Z_scripterrlog("Starting putpixels()%s\n");
1060 //sdci[1]=layer
1061 //sdci[2]=array {x,y,colour,opacity}
1062 //sdci[3]=rotation anchor x
1063 //sdci[4]=rotation anchor y
1064 //sdci[5]=rotation angle
1065
1066
1067 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1068
1069 if(!v_ptr)
1070 {
1071 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
1072 return;
1073 }
1074
1075 std::vector<int32_t> &v = *v_ptr;
1076
1077 if(v.empty())
1078 return;
1079
1080 int32_t* pos = &v[0];
1081 int32_t sz = v.size();
1082
1083
1084 int32_t x1 = 0;
1085 int32_t y1 = 0;
1086
1087 for ( int32_t q = 0; q < sz; q+=4 )
1088 {
1089 x1 = v.at(q); //pos[q];
1090 y1 = v.at(q+1); //pos[q+1];
1091 if(sdci[5]!=0) //rotation
1092 {
1093 int32_t xy[2];
1094 int32_t rx=sdci[3]/10000;
1095 int32_t ry=sdci[4]/10000;
1096 fixed ra1=itofix(sdci[5]%10000)/10000;
1097 fixed ra2=itofix(sdci[5]/10000);
1098 fixed ra=ra1+ra2;
1099
1100 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1101 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1102 x1=xy[0];
1103 y1=xy[1];
1104 }
1105 if ( v.at(q+3) /*pos[q+3]*/ < 128 ) drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
1106 else drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1107 putpixel(bmp, x1+xoffset, y1+yoffset, v.at(q+2) /*pos[q+2]*/);
1108 }
1109 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
1110 }
1111
1112 2302534 void do_drawtiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1113 {
1114 //sdci[1]=layer
1115 //sdci[2]=x
1116 //sdci[3]=y
1117 //sdci[4]=tile
1118 //sdci[5]=tile width
1119 //sdci[6]=tile height
1120 //sdci[7]=color (cset)
1121 //sdci[8]=scale x
1122 //sdci[9]=scale y
1123 //sdci[10]=rotation anchor x
1124 //sdci[11]=rotation anchor y
1125 //sdci[12]=rotation angle
1126 //sdci[13]=flip
1127 //sdci[14]=transparency
1128 //sdci[15]=opacity
1129
1130 2302534 int32_t w = sdci[5]/10000;
1131 2302534 int32_t h = sdci[6]/10000;
1132
1133
4/8
✓ Branch 0 taken 2302534 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2302534 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2302534 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2302534 times.
2302534 if(w < 1 || h < 1 || h > 20 || w > 20)
1134 {
1135 return;
1136 }
1137
1138 2302534 int32_t xscale=sdci[8]/10000;
1139 2302534 int32_t yscale=sdci[9]/10000;
1140 2302534 int32_t rx = sdci[10]/10000;
1141 2302534 int32_t ry = sdci[11]/10000;
1142 2302534 float rotation=sdci[12]/10000;
1143 2302534 int32_t flip=(sdci[13]/10000)&3;
1144 2302534 bool transparency=sdci[14]!=0;
1145 2302534 int32_t opacity=sdci[15]/10000;
1146 2302534 int32_t color=sdci[7]/10000;
1147
1148 2302534 int32_t x1=sdci[2]/10000;
1149 2302534 int32_t y1=sdci[3]/10000;
1150
1151 //don't scale if it's not safe to do so
1152 2302534 bool canscale = true;
1153
1154
3/4
✓ Branch 0 taken 2281889 times.
✓ Branch 1 taken 20645 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2281889 times.
2302534 if(xscale==0||yscale==0)
1155 {
1156 20645 return;
1157 }
1158
1159
3/4
✓ Branch 0 taken 141060 times.
✓ Branch 1 taken 2140829 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 141060 times.
2281889 if(xscale<=0||yscale<=0)
1160 2140829 canscale = false; //default size
1161
1162
4/4
✓ Branch 0 taken 141060 times.
✓ Branch 1 taken 2140829 times.
✓ Branch 2 taken 140626 times.
✓ Branch 3 taken 2000203 times.
2281889 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
1163 {
1164 281686 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16);
1165
1166
1/2
✓ Branch 0 taken 281686 times.
✗ Branch 1 not taken.
281686 if(transparency) //transparency
1167 {
1168 281686 TileHelper::OverTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
1169 281686 }
1170 else //no transparency
1171 {
1172 TileHelper::OldPutTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
1173 }
1174
1175
2/2
✓ Branch 0 taken 144314 times.
✓ Branch 1 taken 137372 times.
281686 if(rotation != 0)
1176 {
1177 //low negative values indicate no anchor-point rotation
1178
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 144314 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
144314 if(rx>-777||ry>-777)
1179 {
1180 int32_t xy[2];
1181 144314 fixed ra1=itofix(sdci[12]%10000)/10000;
1182 144314 fixed ra2=itofix(sdci[12]/10000);
1183 144314 fixed ra=ra1+ra2;
1184 144314 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1185 144314 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1186 144314 x1=xy[0];
1187 144314 y1=xy[1];
1188 144314 }
1189
1190
2/2
✓ Branch 0 taken 3688 times.
✓ Branch 1 taken 140626 times.
144314 if(canscale) //scale first
1191 {
1192 //damnit all, .. fixme.
1193
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3688 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 3688 times.
3688 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
1194 3688 clear_bitmap(tempbit);
1195
1196 3688 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
1197
1198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3688 times.
3688 if(opacity < 128)
1199 {
1200 clear_bitmap(prim_bmp);
1201 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
1202 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1203 }
1204 else
1205 {
1206 3688 rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1207 }
1208
1209 3688 destroy_bitmap(tempbit);
1210 3688 }
1211 else //no scale
1212 {
1213
2/2
✓ Branch 0 taken 3586 times.
✓ Branch 1 taken 137040 times.
140626 if(opacity < 128)
1214 {
1215 3586 clear_bitmap(prim_bmp);
1216 3586 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
1217 3586 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1218 3586 }
1219 else
1220 {
1221 137040 rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1222 }
1223 }
1224 144314 }
1225 else //scale only
1226 {
1227
1/2
✓ Branch 0 taken 137372 times.
✗ Branch 1 not taken.
137372 if(canscale)
1228 {
1229
2/2
✓ Branch 0 taken 4344 times.
✓ Branch 1 taken 133028 times.
137372 if(opacity<128)
1230 {
1231 4344 clear_bitmap(prim_bmp);
1232 4344 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
1233 4344 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1234 4344 }
1235 else
1236 {
1237 133028 stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
1238 }
1239 137372 }
1240 else //error -do not scale
1241 {
1242 if(opacity<128)
1243 {
1244 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1245 }
1246 else
1247 {
1248 draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset);
1249 }
1250 }
1251 }
1252
1253 281686 script_drawing_commands.ReleaseSubBitmap(pbitty);
1254
1255 281686 }
1256 else // no scale or rotation
1257 {
1258
2/2
✓ Branch 0 taken 1972749 times.
✓ Branch 1 taken 27454 times.
2000203 if(transparency)
1259 {
1260
2/2
✓ Branch 0 taken 224767 times.
✓ Branch 1 taken 1747982 times.
1972749 if(opacity<=127)
1261 224767 TileHelper::OverTileTranslucent(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
1262 else
1263 1747982 TileHelper::OverTile(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
1264 1972749 }
1265 else
1266 {
1267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27454 times.
27454 if(opacity<=127)
1268 TileHelper::PutTileTranslucent(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
1269 else
1270 27454 TileHelper::OldPutTile(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
1271 }
1272 }
1273 2302534 }
1274
1275 void do_drawtilecloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1276 {
1277 //sdci[1]=layer
1278 //sdci[2]=x
1279 //sdci[3]=y
1280 //sdci[4]=tile
1281 //sdci[5]=tile width
1282 //sdci[6]=tile height
1283 //sdci[7]=flip
1284
1285 int32_t w = sdci[5]/10000;
1286 int32_t h = sdci[6]/10000;
1287
1288 if(w < 1 || h < 1 || h > 20 || w > 20)
1289 {
1290 return;
1291 }
1292
1293 int32_t flip=(sdci[7]/10000)&3;
1294
1295 int32_t x1=sdci[2]/10000;
1296 int32_t y1=sdci[3]/10000;
1297
1298 TileHelper::OverTileCloaked(bmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, flip);
1299 }
1300
1301
1302 2761920 void do_drawcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1303 {
1304 //sdci[1]=layer
1305 //sdci[2]=x
1306 //sdci[3]=y
1307 //sdci[4]=combo
1308 //sdci[5]=tile width
1309 //sdci[6]=tile height
1310 //sdci[7]=color (cset)
1311 //sdci[8]=scale x
1312 //sdci[9]=scale y
1313 //sdci[10]=rotation anchor x
1314 //sdci[11]=rotation anchor y
1315 //sdci[12]=rotation angle
1316 //sdci[13]=frame
1317 //sdci[14]=flip
1318 //sdci[15]=transparency
1319 //sdci[16]=opacity
1320
1321 2761920 int32_t w = sdci[5]/10000;
1322 2761920 int32_t h = sdci[6]/10000;
1323
1324
4/8
✓ Branch 0 taken 2761920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2761920 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2761920 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 2761920 times.
2761920 if(w<1||h<1||h>20||w>20)
1325 {
1326 return;
1327 }
1328 2761920 int32_t cmb = (sdci[4]/10000);
1329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2761920 times.
2761920 if((unsigned)cmb >= MAXCOMBOS)
1330 {
1331 Z_scripterrlog("DrawCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1332 return;
1333 }
1334
1335 2761920 int32_t xscale=sdci[8]/10000;
1336 2761920 int32_t yscale=sdci[9]/10000;
1337 2761920 int32_t rx = sdci[10]/10000; //these work now
1338 2761920 int32_t ry = sdci[11]/10000; //these work now
1339 2761920 float rotation=sdci[12]/10000;
1340
1341 2761920 bool transparency=sdci[15]!=0;
1342 2761920 int32_t opacity=sdci[16]/10000;
1343 2761920 int32_t color=sdci[7]/10000;
1344 2761920 int32_t x1=sdci[2]/10000;
1345 2761920 int32_t y1=sdci[3]/10000;
1346
1347 2761920 auto& c = GET_DRAWING_COMBO(cmb);
1348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2761920 times.
2761920 if(c.animflags & AF_EDITOR_ONLY) return;
1349 2761920 int32_t tiletodraw = combo_tile(c, x1, y1);
1350 2761920 int32_t flip = ((sdci[14]/10000) & 3) ^ c.flip;
1351 2761920 int32_t skiprows=c.skipanimy;
1352
1353
1354 //don't scale if it's not safe to do so
1355 2761920 bool canscale = true;
1356
1357
3/4
✓ Branch 0 taken 2761847 times.
✓ Branch 1 taken 73 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2761847 times.
2761920 if(xscale==0||yscale==0)
1358 {
1359 73 return;
1360 }
1361
1362
3/4
✓ Branch 0 taken 23422 times.
✓ Branch 1 taken 2738425 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 23422 times.
2761847 if(xscale<=0||yscale<=0)
1363 2738425 canscale = false; //default size
1364
1365
4/4
✓ Branch 0 taken 23422 times.
✓ Branch 1 taken 2738425 times.
✓ Branch 2 taken 109319 times.
✓ Branch 3 taken 2629106 times.
2761847 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
1366 {
1367 132741 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D
1368
1369
2/2
✓ Branch 0 taken 131705 times.
✓ Branch 1 taken 1036 times.
132741 if(transparency)
1370 {
1371 131705 TileHelper::OverTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
1372 131705 }
1373 else //no transparency
1374 {
1375 1036 TileHelper::OldPutTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
1376 }
1377
1378
2/2
✓ Branch 0 taken 109537 times.
✓ Branch 1 taken 23204 times.
132741 if(rotation != 0) // rotate
1379 {
1380 //fixed point sucks ;0
1381
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 109537 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
109537 if(rx>-777||ry>-777) //set the rotation anchor and rotate around that
1382 {
1383 int32_t xy[2];
1384 109537 fixed ra1=itofix(sdci[12]%10000)/10000;
1385 109537 fixed ra2=itofix(sdci[12]/10000);
1386 109537 fixed ra=ra1+ra2;
1387 109537 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
1388 109537 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
1389 109537 x1=xy[0];
1390 109537 y1=xy[1];
1391 109537 }
1392
1393
2/2
✓ Branch 0 taken 218 times.
✓ Branch 1 taken 109319 times.
109537 if(canscale) //scale first
1394 {
1395
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 218 times.
218 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
1396 218 clear_bitmap(tempbit);
1397
1398 218 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
1399
1400
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 218 times.
218 if(opacity < 128)
1401 {
1402 clear_bitmap(prim_bmp);
1403 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
1404 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1405 }
1406 else
1407 {
1408 218 rotate_sprite(bmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1409 }
1410
1411 218 destroy_bitmap(tempbit);
1412 218 }
1413 else //no scale
1414 {
1415
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 109319 times.
109319 if(opacity < 128)
1416 {
1417 clear_bitmap(prim_bmp);
1418 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
1419 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1420 }
1421 else
1422 {
1423 109319 rotate_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
1424 }
1425 }
1426 109537 }
1427 else //scale only
1428 {
1429
1/2
✓ Branch 0 taken 23204 times.
✗ Branch 1 not taken.
23204 if(canscale)
1430 {
1431
2/2
✓ Branch 0 taken 9395 times.
✓ Branch 1 taken 13809 times.
23204 if(opacity<128)
1432 {
1433 9395 clear_bitmap(prim_bmp);
1434 9395 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
1435 9395 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1436 9395 }
1437 else
1438 {
1439 13809 stretch_sprite(bmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
1440 }
1441 23204 }
1442 else //error -do not scale
1443 {
1444 if(opacity<128)
1445 {
1446 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
1447 }
1448 else
1449 {
1450 draw_sprite(bmp, pbitty, x1+xoffset, y1+yoffset);
1451 }
1452 }
1453 }
1454
1455 132741 script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks
1456 132741 }
1457 else // no scale or rotation
1458 {
1459
1/2
✓ Branch 0 taken 2629106 times.
✗ Branch 1 not taken.
2629106 if(transparency)
1460 {
1461
2/2
✓ Branch 0 taken 64341 times.
✓ Branch 1 taken 2564765 times.
2629106 if(opacity<=127)
1462 64341 TileHelper::OverTileTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1463 else
1464 2564765 TileHelper::OverTile(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1465 2629106 }
1466 else
1467 {
1468 if(opacity<=127)
1469 TileHelper::PutTileTranslucent(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
1470 else
1471 TileHelper::OldPutTile(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
1472 }
1473 }
1474 2761920 }
1475
1476 void do_drawcombocloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1477 {
1478 //sdci[1]=layer
1479 //sdci[2]=x
1480 //sdci[3]=y
1481 //sdci[4]=combo
1482 //sdci[5]=tile width
1483 //sdci[6]=tile height
1484 //sdci[7]=flip
1485
1486 int32_t w = sdci[5]/10000;
1487 int32_t h = sdci[6]/10000;
1488
1489 if(w<1||h<1||h>20||w>20)
1490 {
1491 return;
1492 }
1493 int32_t cmb = (sdci[4]/10000);
1494 if((unsigned)cmb >= MAXCOMBOS)
1495 {
1496 Z_scripterrlog("DrawComboCloaked() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1497 return;
1498 }
1499
1500 int32_t x1=sdci[2]/10000;
1501 int32_t y1=sdci[3]/10000;
1502
1503 auto& c = GET_DRAWING_COMBO(cmb);
1504 int32_t tiletodraw = combo_tile(c, x1, y1);
1505 if(c.animflags & AF_EDITOR_ONLY) return;
1506 int32_t flip = ((sdci[7]/10000) & 3) ^ c.flip;
1507 int32_t skiprows=c.skipanimy;
1508
1509 TileHelper::OverTileCloaked(bmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, flip, skiprows);
1510 }
1511
1512
1513 5327982 void do_fasttiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1514 {
1515 /* layer, x, y, tile, color opacity */
1516
1517 5327982 int32_t opacity = sdci[6]/10000;
1518 5327982 int x = xoffset+(sdci[2]/10000);
1519 5327982 int y = yoffset+(sdci[3]/10000);
1520
1521
2/2
✓ Branch 0 taken 154230 times.
✓ Branch 1 taken 5173752 times.
5327982 if(opacity < 128)
1522 154230 overtiletranslucent16(bmp, sdci[4]/10000, x, y, sdci[5]/10000, 0, opacity);
1523 else
1524 5173752 overtile16(bmp, sdci[4]/10000, x, y, sdci[5]/10000, 0);
1525 5327982 }
1526
1527 void do_fasttilesr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1528 {
1529 /* layer, x, y, tile, color opacity */
1530
1531 //sdci[1]=layer
1532 //sdci[2]=array {x,y,tile,colour,opacity}
1533
1534 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1535
1536 if(!v_ptr)
1537 {
1538 al_trace("Screen->PutPixels: Vector pointer is null! Internal error. \n");
1539 return;
1540 }
1541
1542 std::vector<int32_t> &v = *v_ptr;
1543
1544 if(v.empty())
1545 return;
1546
1547 int32_t* pos = &v[0];
1548 int32_t sz = v.size();
1549
1550 for ( int32_t q = 0; q < sz; q+=5 )
1551 {
1552
1553 if(v.at(q+4) < 128)
1554 overtiletranslucent16(bmp, v.at(q+2), xoffset+(v.at(q)), yoffset+(v.at(q+1)), v.at(q+3), 0, v.at(q+4));
1555 else
1556 overtile16(bmp, v.at(q+2), xoffset+(v.at(q)), yoffset+(v.at(q+1)), v.at(q+3), 0);
1557 }
1558 }
1559
1560
1561
1562 30256034 void do_fastcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1563 {
1564 /* layer, x, y, tile, color opacity */
1565
1566 30256034 int32_t opacity = sdci[6] / 10000;
1567 30256034 int32_t x1 = sdci[2] / 10000;
1568 30256034 int32_t y1 = sdci[3] / 10000;
1569
1570 30256034 int32_t cmb = (sdci[4]/10000);
1571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30256034 times.
30256034 if((unsigned)cmb >= MAXCOMBOS)
1572 {
1573 Z_scripterrlog("FastCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
1574 return;
1575 }
1576
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30256034 times.
30256034 if(combobuf[cmb].animflags & AF_EDITOR_ONLY) return;
1577
1578 30256034 int x = xoffset+x1;
1579 30256034 int y = yoffset+y1;
1580
1581
2/2
✓ Branch 0 taken 7829244 times.
✓ Branch 1 taken 22426790 times.
30256034 if(opacity < 128)
1582 {
1583 7829244 overcomboblocktranslucent(bmp, x, y, cmb, sdci[5]/10000, 1, 1, 128);
1584 7829244 }
1585 else
1586 {
1587 22426790 overcomboblock(bmp, x, y, cmb, sdci[5]/10000, 1, 1);
1588 }
1589 30256034 }
1590
1591 void do_fastcombosr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1592 {
1593 /* layer, x, y, combo, cset, opacity */
1594 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
1595
1596 if(!v_ptr)
1597 {
1598 al_trace("Screen->FastCombos: Vector pointer is null! Internal error. \n");
1599 return;
1600 }
1601
1602 std::vector<int32_t> &v = *v_ptr;
1603
1604 if(v.empty())
1605 return;
1606
1607 int32_t* pos = &v[0];
1608 int32_t sz = v.size();
1609
1610 for ( int32_t q = 0; q < sz; q+=5 )
1611 {
1612 auto cid = v.at(q+2);
1613 if((unsigned)(cid) >= MAXCOMBOS)
1614 {
1615 Z_scripterrlog("FastCombos() cannot draw combo '%d', as it is out of bounds.\n", v.at(q+2));
1616 continue;
1617 }
1618 if(combobuf[cid].animflags & AF_EDITOR_ONLY) continue;
1619 if(v.at(q+4) < 128)
1620 {
1621 overcomboblocktranslucent(bmp, xoffset+v.at(q), yoffset+v.at(q+1), v.at(q+2), v.at(q+3), 1, 1, 128);
1622
1623 }
1624 else
1625 {
1626 overcomboblock(bmp, xoffset+v.at(q), yoffset+v.at(q+1), v.at(q+2), v.at(q+3), 1, 1);
1627 }
1628 }
1629 }
1630
1631
1632
1633
1634 964155 void do_drawcharr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1635 {
1636 //broken 2.50.2 and earlier drawcharacter()
1637
2/2
✓ Branch 0 taken 18543 times.
✓ Branch 1 taken 945612 times.
964155 if ( get_qr(qr_BROKENCHARINTDRAWING) )
1638 {
1639 //sdci[1]=layer
1640 //sdci[2]=x
1641 //sdci[3]=y
1642 //sdci[4]=font
1643 //sdci[5]=color
1644 //sdci[6]=bg color
1645 //sdci[7]=strech x (width)
1646 //sdci[8]=stretch y (height)
1647 //sdci[9]=char
1648 //sdci[10]=opacity
1649
1650 18543 int32_t x=sdci[2]/10000;
1651 18543 int32_t y=sdci[3]/10000;
1652 18543 int32_t font_index=sdci[4]/10000;
1653 18543 int32_t color=sdci[5]/10000;
1654 18543 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1655 18543 int32_t w=sdci[7]/10000;
1656 18543 int32_t h=sdci[8]/10000;
1657 18543 char glyph=char(sdci[9]/10000);
1658 18543 int32_t opacity=sdci[10]/10000;
1659
1660 //safe check
1661
1/2
✓ Branch 0 taken 18543 times.
✗ Branch 1 not taken.
18543 if(bg_color < -1) bg_color = -1;
1662
1663
1/2
✓ Branch 0 taken 18543 times.
✗ Branch 1 not taken.
18543 if(w>512) w=512; //w=vbound(w,0,512);
1664
1665
1/2
✓ Branch 0 taken 18543 times.
✗ Branch 1 not taken.
18543 if(h>512) h=512; //h=vbound(h,0,512);
1666
1667 //undone
1668
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 18543 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
18543 if(w>0&&h>0)//stretch the character
1669 {
1670 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1671
1672 if(opacity < 128)
1673 {
1674 if(w>128||h>128)
1675 {
1676 clear_bitmap(prim_bmp);
1677
1678 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1679 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1680 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1681 }
1682 else //this is faster
1683 {
1684 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
1685
1686 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1687 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1688 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1689
1690 script_drawing_commands.ReleaseSubBitmap(pbmp2);
1691 }
1692 }
1693 else // no opacity
1694 {
1695 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1696 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1697 }
1698
1699 }
1700 else //no stretch
1701 {
1702
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18543 times.
18543 if(opacity < 128)
1703 {
1704 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1705 clear_bitmap(pbmp);
1706
1707 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1708 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1709
1710 destroy_bitmap(pbmp);
1711 }
1712 else // no opacity
1713 {
1714 18543 textprintf_ex(bmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
1715 }
1716 }
1717 18543 }
1718
1719 else //2.53.0 fixed version and later.
1720 {
1721
1722 //sdci[1]=layer
1723 //sdci[2]=x
1724 //sdci[3]=y
1725 //sdci[4]=font
1726 //sdci[5]=color
1727 //sdci[6]=bg color
1728 //sdci[7]=strech x (width)
1729 //sdci[8]=stretch y (height)
1730 //sdci[9]=char
1731 //sdci[10]=opacity
1732
1733 945612 int32_t x=sdci[2]/10000;
1734 945612 int32_t y=sdci[3]/10000;
1735 945612 int32_t font_index=sdci[4]/10000;
1736 945612 int32_t color=sdci[5]/10000;
1737 945612 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1738 945612 int32_t w=sdci[7]/10000;
1739 945612 int32_t h=sdci[8]/10000;
1740 945612 char glyph=char(sdci[9]/10000);
1741 945612 int32_t opacity=sdci[10]/10000;
1742
1743 //safe check
1744
1/2
✓ Branch 0 taken 945612 times.
✗ Branch 1 not taken.
945612 if(bg_color < -1) bg_color = -1;
1745
1746
1/2
✓ Branch 0 taken 945612 times.
✗ Branch 1 not taken.
945612 if(w>512) w=512; //w=vbound(w,0,512);
1747
1748
1/2
✓ Branch 0 taken 945612 times.
✗ Branch 1 not taken.
945612 if(h>512) h=512; //h=vbound(h,0,512);
1749
1750 //undone
1751
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 945612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
945612 if(w>0&&h>0)//stretch the character
1752 {
1753 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1754
1755 if(opacity < 128)
1756 {
1757 if(w>128||h>128)
1758 {
1759 clear_bitmap(prim_bmp);
1760
1761 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1762 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1763 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1764 }
1765 else //this is faster
1766 {
1767 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
1768
1769 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1770 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1771 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1772
1773 script_drawing_commands.ReleaseSubBitmap(pbmp2);
1774 }
1775 }
1776 else // no opacity
1777 {
1778 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1779 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1780 }
1781
1782 }
1783 else //no stretch
1784 {
1785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 945612 times.
945612 if(opacity < 128)
1786 {
1787 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1788 clear_bitmap(pbmp);
1789
1790 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
1791 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1792
1793 destroy_bitmap(pbmp);
1794 }
1795 else // no opacity
1796 {
1797 945612 textprintf_ex(bmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
1798 }
1799 }
1800
1801 }
1802
1803 964155 }
1804
1805
1806 176452 void do_drawintr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
1807 {
1808 //broken 2.50.2 and earlier drawinteger()
1809
2/2
✓ Branch 0 taken 72655 times.
✓ Branch 1 taken 103797 times.
176452 if ( get_qr(qr_BROKENCHARINTDRAWING) )
1810 {
1811 //sdci[1]=layer
1812 //sdci[2]=x
1813 //sdci[3]=y
1814 //sdci[4]=font
1815 //sdci[5]=color
1816 //sdci[6]=bg color
1817 //sdci[7]=strech x (width)
1818 //sdci[8]=stretch y (height)
1819 //sdci[9]=integer
1820 //sdci[10]=num decimal places
1821 //sdci[11]=opacity
1822
1823 72655 int32_t x=sdci[2]/10000;
1824 72655 int32_t y=sdci[3]/10000;
1825 72655 int32_t font_index=sdci[4]/10000;
1826 72655 int32_t color=sdci[5]/10000;
1827 72655 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1828 72655 int32_t w=sdci[7]/10000;
1829 72655 int32_t h=sdci[8]/10000;
1830 72655 int32_t decplace=sdci[10]/10000;
1831 72655 int32_t opacity=sdci[11]/10000;
1832
1833 //safe check
1834
1/2
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
72655 if(bg_color < -1) bg_color = -1;
1835
1836
1/2
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
72655 if(w>512) w=512; //w=vbound(w,0,512);
1837
1838
1/2
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
72655 if(h>512) h=512; //h=vbound(h,0,512);
1839
1840 char numbuf[15];
1841
1842
1/6
✓ Branch 0 taken 72655 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
72655 switch(decplace)
1843 {
1844 default:
1845 case 0:
1846 72655 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
1847 72655 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
1848
1849 case 1:
1850 //sprintf(numbuf,"%.01f",number);
1851 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
1852 break;
1853
1854 case 2:
1855 //sprintf(numbuf,"%.02f",number);
1856 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
1857 break;
1858
1859 case 3:
1860 //sprintf(numbuf,"%.03f",number);
1861 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
1862 break;
1863
1864 case 4:
1865 //sprintf(numbuf,"%.04f",number);
1866 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
1867 break;
1868 }
1869
1870
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 72655 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
72655 if(w>0&&h>0)//stretch
1871 {
1872 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
1873
1874 if(opacity < 128)
1875 {
1876 if(w>128||h>128)
1877 {
1878 clear_bitmap(prim_bmp);
1879
1880 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1881 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
1882 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
1883 }
1884 else
1885 {
1886 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
1887 clear_bitmap(pbmp2);
1888
1889 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1890 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
1891 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
1892
1893 destroy_bitmap(pbmp2);
1894 }
1895 }
1896 else // no opacity
1897 {
1898 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1899 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
1900 }
1901
1902 }
1903 else //no stretch
1904 {
1905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 72655 times.
72655 if(opacity < 128)
1906 {
1907 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
1908 clear_bitmap(pbmp);
1909
1910 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1911 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
1912
1913 destroy_bitmap(pbmp);
1914 }
1915 else // no opacity
1916 {
1917 72655 textout_ex(bmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
1918 }
1919 }
1920
1921 72655 }
1922
1923 else //2.53.0 fixed version and later.
1924 {
1925 //sdci[1]=layer
1926 //sdci[2]=x
1927 //sdci[3]=y
1928 //sdci[4]=font
1929 //sdci[5]=color
1930 //sdci[6]=bg color
1931 //sdci[7]=strech x (width)
1932 //sdci[8]=stretch y (height)
1933 //sdci[9]=integer
1934 //sdci[10]=num decimal places
1935 //sdci[11]=opacity
1936
1937 103797 int32_t x=sdci[2]/10000;
1938 103797 int32_t y=sdci[3]/10000;
1939 103797 int32_t font_index=sdci[4]/10000;
1940 103797 int32_t color=sdci[5]/10000;
1941 103797 int32_t bg_color=sdci[6]/10000; //-1 = transparent
1942 103797 int32_t w=sdci[7]/10000;
1943 103797 int32_t h=sdci[8]/10000;
1944 103797 int32_t decplace=sdci[10]/10000;
1945 103797 int32_t opacity=sdci[11]/10000;
1946
1947 //safe check
1948
1/2
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
103797 if(bg_color < -1) bg_color = -1;
1949
1950
1/2
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
103797 if(w>512) w=512; //w=vbound(w,0,512);
1951
1952
1/2
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
103797 if(h>512) h=512; //h=vbound(h,0,512);
1953
1954 char numbuf[15];
1955
1956
1/6
✓ Branch 0 taken 103797 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
103797 switch(decplace)
1957 {
1958 default:
1959 case 0:
1960 103797 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
1961 103797 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
1962
1963 case 1:
1964 //sprintf(numbuf,"%.01f",number);
1965 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
1966 break;
1967
1968 case 2:
1969 //sprintf(numbuf,"%.02f",number);
1970 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
1971 break;
1972
1973 case 3:
1974 //sprintf(numbuf,"%.03f",number);
1975 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
1976 break;
1977
1978 case 4:
1979 //sprintf(numbuf,"%.04f",number);
1980 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
1981 break;
1982 }
1983
1984 //FONT* font=get_zc_font(sdci[4]/10000);
1985
1986
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 103797 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
103797 if(w>0&&h>0)//stretch
1987 {
1988 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(get_zc_font(font_index), numbuf)+1, text_height(get_zc_font(font_index)));
1989 clear_bitmap(pbmp);
1990 //script_drawing_commands.GetSmallTextureBitmap(1,1);
1991
1992 if(opacity < 128)
1993 {
1994 if(w>128||h>128)
1995 {
1996 clear_bitmap(prim_bmp);
1997
1998 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
1999 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
2000 draw_trans_sprite(bmp, prim_bmp, x+xoffset, y+yoffset);
2001 }
2002 else
2003 {
2004 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
2005 clear_bitmap(pbmp2);
2006
2007 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
2008 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
2009 draw_trans_sprite(bmp, pbmp2, x+xoffset, y+yoffset);
2010
2011 destroy_bitmap(pbmp2);
2012 }
2013 }
2014 else // no opacity
2015 {
2016 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
2017 stretch_sprite(bmp, pbmp, x+xoffset, y+yoffset, w, h);
2018 }
2019
2020 }
2021 else //no stretch
2022 {
2023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103797 times.
103797 if(opacity < 128)
2024 {
2025 FONT* font = get_zc_font(font_index);
2026 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(font, numbuf), text_height(font));
2027 clear_bitmap(pbmp);
2028
2029 textout_ex(pbmp, font, numbuf, 0, 0, color, bg_color);
2030 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2031
2032 destroy_bitmap(pbmp);
2033 }
2034 else // no opacity
2035 {
2036 103797 textout_ex(bmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
2037 }
2038 }
2039 }
2040 176452 }
2041
2042
2043 1607511 void do_drawstringr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2044 {
2045 //sdci[1]=layer
2046 //sdci[2]=x
2047 //sdci[3]=y
2048 //sdci[4]=font
2049 //sdci[5]=color
2050 //sdci[6]=bg color
2051 //sdci[7]=format_option
2052 //sdci[8]=string
2053 //sdci[9]=opacity
2054
2055 1607511 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
2056
2057
1/2
✓ Branch 0 taken 1607511 times.
✗ Branch 1 not taken.
1607511 if(!str)
2058 {
2059 al_trace("String pointer is null! Internal error. \n");
2060 return;
2061 }
2062
2063 1607511 int32_t x=sdci[2]/10000;
2064 1607511 int32_t y=sdci[3]/10000;
2065 1607511 FONT* font=get_zc_font(sdci[4]/10000);
2066 1607511 int32_t color=sdci[5]/10000;
2067 1607511 int32_t bg_color=sdci[6]/10000; //-1 = transparent
2068 1607511 int32_t format_type=sdci[7]/10000;
2069 1607511 int32_t opacity=sdci[9]/10000;
2070 //sdci[8] not needed :)
2071
2072 //safe check
2073
1/2
✓ Branch 0 taken 1607511 times.
✗ Branch 1 not taken.
1607511 if(bg_color < -1) bg_color = -1;
2074
2075
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1607511 times.
1607511 if(opacity < 128)
2076 {
2077 int32_t width=zc_min(text_length(font, str->c_str()), 512);
2078 if (width < 1) return; //SANITY -Em
2079 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
2080 clear_bitmap(pbmp);
2081 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
2082 if(format_type == 2) // right-sided text
2083 x-=width;
2084 else if(format_type == 1) // centered text
2085 x-=width/2;
2086 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2087 destroy_bitmap(pbmp);
2088 }
2089 else // no opacity
2090 {
2091
2/2
✓ Branch 0 taken 14345 times.
✓ Branch 1 taken 1593166 times.
1607511 if(format_type == 2) // right-sided text
2092 {
2093 14345 textout_right_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2094 14345 }
2095
2/2
✓ Branch 0 taken 725712 times.
✓ Branch 1 taken 867454 times.
1593166 else if(format_type == 1) // centered text
2096 {
2097 725712 textout_centre_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2098 725712 }
2099 else // standard left-sided text
2100 {
2101 867454 textout_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
2102 }
2103 }
2104 1607511 }
2105
2106 201739 void do_drawstringr2(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2107 {
2108 //sdci[1]=layer
2109 //sdci[2]=x
2110 //sdci[3]=y
2111 //sdci[4]=font
2112 //sdci[5]=color
2113 //sdci[6]=bg color
2114 //sdci[7]=format_option
2115 //sdci[8]=string
2116 //sdci[9]=opacity
2117 //sdci[10]=shadowtype
2118 //sdci[11]=shadow_color
2119
2120 201739 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
2121
2122
1/2
✓ Branch 0 taken 201739 times.
✗ Branch 1 not taken.
201739 if(!str)
2123 {
2124 al_trace("String pointer is null! Internal error. \n");
2125 return;
2126 }
2127
2128 201739 int32_t x=sdci[2]/10000;
2129 201739 int32_t y=sdci[3]/10000;
2130 201739 FONT* font=get_zc_font(sdci[4]/10000);
2131 201739 int32_t color=sdci[5]/10000;
2132 201739 int32_t bg_color=sdci[6]/10000; //-1 = transparent
2133 201739 int32_t format_type=sdci[7]/10000;
2134 201739 int32_t opacity=sdci[9]/10000;
2135 201739 int32_t textstyle = sdci[10]/10000;
2136 201739 int32_t shadow_color = sdci[11]/10000;
2137 //sdci[8] not needed :)
2138
2139 //safe check
2140
1/2
✓ Branch 0 taken 201739 times.
✗ Branch 1 not taken.
201739 if(bg_color < -1) bg_color = -1;
2141
2142
2/2
✓ Branch 0 taken 740 times.
✓ Branch 1 taken 200999 times.
201739 if(opacity < 128)
2143 {
2144
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 int32_t width=zc_min(text_length(font, str->c_str()), 512);
2145
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 if (width < 1) return; //SANITY -Em
2146 740 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
2147 740 clear_bitmap(pbmp);
2148 740 textout_styled_aligned_ex(pbmp, font, str->c_str(), 0, 0, textstyle, ALIGN_LEFT, color, shadow_color, bg_color);
2149 740 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
2150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 740 times.
740 if(format_type == 2) // right-sided text
2151 x-=width;
2152
1/2
✓ Branch 0 taken 740 times.
✗ Branch 1 not taken.
740 else if(format_type == 1) // centered text
2153 740 x-=width/2;
2154 740 draw_trans_sprite(bmp, pbmp, x+xoffset, y+yoffset);
2155 740 destroy_bitmap(pbmp);
2156 740 }
2157 else // no opacity
2158 {
2159 200999 textout_styled_aligned_ex(bmp, font, str->c_str(), x+xoffset, y+yoffset, textstyle, format_type, color, shadow_color, bg_color);
2160 }
2161 201739 }
2162
2163
2164 9266 void do_drawquadr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2165 {
2166 //sdci[1]=layer
2167 //sdci[2]=x1
2168 //sdci[3]=y1
2169 //sdci[4]=x2
2170 //sdci[5]=y2
2171 //sdci[6]=x3
2172 //sdci[7]=y3
2173 //sdci[8]=x4
2174 //sdci[9]=y4
2175 //sdci[10]=width
2176 //sdci[11]=height
2177 //sdci[12]=cset
2178 //sdci[13]=flip
2179 //sdci[14]=tile/combo
2180 //sdci[15]=polytype
2181
2182 9266 int32_t x1 = sdci[2]/10000;
2183 9266 int32_t y1 = sdci[3]/10000;
2184 9266 int32_t x2 = sdci[4]/10000;
2185 9266 int32_t y2 = sdci[5]/10000;
2186 9266 int32_t x3 = sdci[6]/10000;
2187 9266 int32_t y3 = sdci[7]/10000;
2188 9266 int32_t x4 = sdci[8]/10000;
2189 9266 int32_t y4 = sdci[9]/10000;
2190 9266 int32_t w = sdci[10]/10000;
2191 9266 int32_t h = sdci[11]/10000;
2192 9266 int32_t color = sdci[12]/10000;
2193 9266 int32_t flip=(sdci[13]/10000)&3;
2194 9266 int32_t tile = sdci[14]/10000;
2195 9266 int32_t polytype = sdci[15]/10000;
2196
2197 //todo: finish palette shading
2198 /*
2199 POLYTYPE_FLAT
2200 POLYTYPE_GCOL
2201 POLYTYPE_GRGB
2202 POLYTYPE_ATEX
2203 POLYTYPE_PTEX
2204 POLYTYPE_ATEX_MASK
2205 POLYTYPE_PTEX_MASK
2206 POLYTYPE_ATEX_LIT
2207 POLYTYPE_PTEX_LIT
2208 POLYTYPE_ATEX_MASK_LIT
2209 POLYTYPE_PTEX_MASK_LIT
2210 POLYTYPE_ATEX_TRANS
2211 POLYTYPE_PTEX_TRANS
2212 POLYTYPE_ATEX_MASK_TRANS
2213 POLYTYPE_PTEX_MASK_TRANS
2214 */
2215 9266 polytype = vbound(polytype, 0, 14);
2216
2217
2/4
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9266 times.
9266 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
2218 {
2219 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
2220 return; //non power of two error
2221 }
2222
2223 9266 int32_t tex_width = w*16;
2224 9266 int32_t tex_height = h*16;
2225
2226 BITMAP *tex;
2227
2228 9266 bool mustDestroyBmp = false;
2229
2230
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if ( tile > 65519 ) tex = zscriptDrawingRenderTarget->GetBitmapPtr(tile - 65519);
2231 9266 else tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
2232
2233
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if(!tex)
2234 {
2235 mustDestroyBmp = true;
2236 tex = create_bitmap_ex(8, tex_width, tex_height);
2237 clear_bitmap(tex);
2238 }
2239
2240 int32_t col[4];
2241 /*
2242 if( color < 0 )
2243 {
2244 col[0]=draw_container.color_buffer[0];
2245 col[1]=draw_container.color_buffer[1];
2246 col[2]=draw_container.color_buffer[2];
2247 col[3]=draw_container.color_buffer[3];
2248 }
2249 else */
2250 {
2251 9266 col[0]=col[1]=col[2]=col[3]=color;
2252 }
2253
2254
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
9266 if(tile > 0 && tile <= 65519) // TILE
2255 {
2256 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
2257 }
2258
2259
1/2
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
9266 if ( tile < 0 ) // COMBO
2260 {
2261 9266 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
2262 9266 const int32_t tiletodraw = combo_tile(c, x1, y1);
2263 9266 flip = flip ^ c.flip;
2264
2265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9266 times.
9266 if(!(c.animflags & AF_EDITOR_ONLY))
2266 9266 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
2267 9266 }
2268
2269 9266 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
2270 9266 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
2271 9266 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
2272 9266 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(tex_width), 0, col[3] };
2273
2274 9266 quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
2275
2276
1/2
✓ Branch 0 taken 9266 times.
✗ Branch 1 not taken.
9266 if(mustDestroyBmp)
2277 destroy_bitmap(tex);
2278
2279 9266 }
2280
2281
2282 void do_drawtriangler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2283 {
2284 //sdci[1]=layer
2285 //sdci[2]=x1
2286 //sdci[3]=y1
2287 //sdci[4]=x2
2288 //sdci[5]=y2
2289 //sdci[6]=x3
2290 //sdci[7]=y3
2291 //sdci[8]=width
2292 //sdci[9]=height
2293 //sdci[10]=cset
2294 //sdci[11]=flip
2295 //sdci[12]=tile/combo
2296 //sdci[13]=polytype
2297
2298 int32_t x1 = sdci[2]/10000;
2299 int32_t y1 = sdci[3]/10000;
2300 int32_t x2 = sdci[4]/10000;
2301 int32_t y2 = sdci[5]/10000;
2302 int32_t x3 = sdci[6]/10000;
2303 int32_t y3 = sdci[7]/10000;
2304 int32_t w = sdci[8]/10000;
2305 int32_t h = sdci[9]/10000;
2306 int32_t color = sdci[10]/10000;
2307 int32_t flip=(sdci[11]/10000)&3;
2308 int32_t tile = sdci[12]/10000;
2309 int32_t polytype = sdci[13]/10000;
2310
2311 polytype = vbound(polytype, 0, 14);
2312
2313 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
2314 {
2315 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
2316 return; //non power of two error
2317 }
2318
2319 int32_t tex_width = w*16;
2320 int32_t tex_height = h*16;
2321
2322 bool mustDestroyBmp = false;
2323 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
2324
2325 if(!tex)
2326 {
2327 mustDestroyBmp = true;
2328 tex = create_bitmap_ex(8, tex_width, tex_height);
2329 clear_bitmap(tex);
2330 }
2331
2332 int32_t col[3];
2333 /*
2334 if( color < 0 )
2335 {
2336 col[0]=draw_container.color_buffer[0];
2337 col[1]=draw_container.color_buffer[1];
2338 col[2]=draw_container.color_buffer[2];
2339 }
2340 else */
2341 {
2342 col[0]=col[1]=col[2]=color;
2343 }
2344
2345 if(tile > 0) // TILE
2346 {
2347 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
2348 }
2349 else // COMBO
2350 {
2351 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
2352 const int32_t tiletodraw = combo_tile(c, x1, y1);
2353 flip = flip ^ c.flip;
2354
2355 if(!(c.animflags & AF_EDITOR_ONLY))
2356 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
2357 }
2358
2359 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
2360 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
2361 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
2362
2363
2364 triangle3d_f(bmp, polytype, tex, &V1, &V2, &V3);
2365
2366 if(mustDestroyBmp)
2367 destroy_bitmap(tex);
2368 }
2369
2370
2371 937483 void do_drawbitmapr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2372 {
2373 //sdci[1]=layer
2374 //sdci[2]=bitmap
2375 //sdci[3]=sourcex
2376 //sdci[4]=sourcey
2377 //sdci[5]=sourcew
2378 //sdci[6]=sourceh
2379 //sdci[7]=destx
2380 //sdci[8]=desty
2381 //sdci[9]=destw
2382 //sdci[10]=desth
2383 //sdci[11]=rotation
2384 //sdci[12]=mask
2385
2386 937483 int32_t bitmapIndex = sdci[2]/10000;
2387 937483 int32_t sx = sdci[3]/10000;
2388 937483 int32_t sy = sdci[4]/10000;
2389 937483 int32_t sw = sdci[5]/10000;
2390 937483 int32_t sh = sdci[6]/10000;
2391 937483 int32_t dx = sdci[7]/10000;
2392 937483 int32_t dy = sdci[8]/10000;
2393 937483 int32_t dw = sdci[9]/10000;
2394 937483 int32_t dh = sdci[10]/10000;
2395 937483 float rot = sdci[11]/10000;
2396 937483 bool masked = (sdci[12] != 0);
2397
2398 //bugfix
2399 937483 sx = vbound(sx, 0, 512);
2400 937483 sy = vbound(sy, 0, 512);
2401 937483 sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well
2402 937483 sh = vbound(sh, 0, 512 - sy);
2403
2404
2405
2/4
✓ Branch 0 taken 937483 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 937483 times.
937483 if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight)
2406 return;
2407
2408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 937483 times.
937483 bool stretched = (sw != dw || sh != dh);
2409
2410 937483 BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
2411
2412
1/2
✓ Branch 0 taken 937483 times.
✗ Branch 1 not taken.
937483 if(!sourceBitmap)
2413 {
2414 Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex);
2415 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
2416 return;
2417 }
2418
2419 937483 BITMAP* subBmp = 0;
2420
2421
1/2
✓ Branch 0 taken 937483 times.
✗ Branch 1 not taken.
937483 if(rot != 0)
2422 {
2423 subBmp = script_drawing_commands.AquireSubBitmap(dw, dh);
2424
2425 if(!subBmp)
2426 {
2427 Z_scripterrlog("DrawBitmap() failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
2428 return;
2429 }
2430 }
2431
2432
2433 937483 dx = dx + xoffset;
2434 937483 dy = dy + yoffset;
2435
2436
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 937243 times.
937483 if(stretched)
2437 {
2438
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(masked)
2439 {
2440
1/2
✓ Branch 0 taken 240 times.
✗ Branch 1 not taken.
240 if(rot != 0)
2441 {
2442 //if ( rot == 4096 ) { //translucent
2443 // masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2444 // //rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2445 // draw_trans_sprite(bmp, subBmp, dx, dy);
2446 // //draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, 0);
2447
2448
2449 // }
2450 //else {
2451 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2452 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2453 //rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2454 //
2455
2456 // }
2457 }
2458 else
2459 240 masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2460 240 }
2461 else
2462 {
2463 if(rot != 0)
2464 {
2465 //if ( rot == 4096 ) { //translucent
2466 // stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2467 // draw_trans_sprite(bmp, subBmp, dx, dy);
2468 // }
2469 //else {
2470 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2471 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2472 // }
2473 }
2474 else
2475 stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2476 }
2477 240 }
2478 else
2479 {
2480
2/2
✓ Branch 0 taken 929755 times.
✓ Branch 1 taken 7488 times.
937243 if(masked)
2481 {
2482
1/2
✓ Branch 0 taken 929755 times.
✗ Branch 1 not taken.
929755 if(rot != 0)
2483 {
2484 //if ( rot == 4096 ) {//translucent
2485 // masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2486 //rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2487
2488 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2489 //rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2490 // draw_trans_sprite(bmp, subBmp, dx, dy);
2491 // }
2492 //else {
2493 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2494 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2495 // }
2496 }
2497 else
2498 929755 masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
2499 929755 }
2500 else
2501 {
2502
1/2
✓ Branch 0 taken 7488 times.
✗ Branch 1 not taken.
7488 if(rot != 0)
2503 {
2504 //if ( rot == 4096 ) { //translucent
2505 // blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2506 // draw_trans_sprite(bmp, subBmp, dx, dy);
2507 // }
2508 //else {
2509 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
2510 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2511 // }
2512 }
2513 else
2514 7488 blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
2515 }
2516 }
2517
2518 //cleanup
2519
1/2
✓ Branch 0 taken 937483 times.
✗ Branch 1 not taken.
937483 if(subBmp)
2520 {
2521 script_drawing_commands.ReleaseSubBitmap(subBmp);
2522 }
2523 937483 }
2524
2525
2526 //Draw]()
2527 void do_drawbitmapexr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
2528 {
2529 /*
2530 //sdci[1]=layer
2531 //sdci[2]=bitmap
2532 //sdci[3]=sourcex
2533 //sdci[4]=sourcey
2534 //sdci[5]=sourcew
2535 //sdci[6]=sourceh
2536 //sdci[7]=destx
2537 //sdci[8]=desty
2538 //sdci[9]=destw
2539 //sdci[10]=desth
2540 //sdci[11]=rotation/angle
2541 //scdi[12] = pivot cx
2542 //sdci[13] = pivot cy
2543 //scdi[14] = effect flags
2544
2545
2546 const int32_t BITDX_NORMAL = 0;
2547 const int32_t BITDX_TRANS = 1; //Translucent
2548 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
2549 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
2550 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
2551 //Note: Some modes cannot be combined. if a combination is not supported, an error
2552 // detailing this will be shown in allegro.log.
2553
2554 //scdi[15] = litcolour
2555 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2556 /not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2557
2558 //sdci[16]=mask
2559
2560 */
2561
2562 int32_t bitmapIndex = sdci[2]/10000;
2563 int32_t sx = sdci[3]/10000;
2564 int32_t sy = sdci[4]/10000;
2565 int32_t sw = sdci[5]/10000;
2566 int32_t sh = sdci[6]/10000;
2567 int32_t dx = sdci[7]/10000;
2568 int32_t dy = sdci[8]/10000;
2569 int32_t dw = sdci[9]/10000;
2570 int32_t dh = sdci[10]/10000;
2571 float rot = sdci[11]/10000;
2572 int32_t cx = sdci[12]/10000;
2573 int32_t cy = sdci[13]/10000;
2574 int32_t mode = sdci[14]/10000;
2575 int32_t litcolour = sdci[15]/10000;
2576 bool masked = (sdci[16] != 0);
2577
2578
2579
2580 //bugfix
2581 sx = vbound(sx, 0, 512);
2582 sy = vbound(sy, 0, 512);
2583 sw = vbound(sw, 0, 512 - sx); //keep the w/h within range as well
2584 sh = vbound(sh, 0, 512 - sy);
2585
2586
2587 if(sx >= ZScriptDrawingRenderTarget::BitmapWidth || sy >= ZScriptDrawingRenderTarget::BitmapHeight)
2588 return;
2589
2590 bool stretched = (sw != dw || sh != dh);
2591
2592 BITMAP *sourceBitmap = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
2593
2594 if(!sourceBitmap)
2595 {
2596 Z_message("Warning: Screen->DrawBitmap(%d) contains invalid data or is not initialized.\n", bitmapIndex);
2597 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
2598 return;
2599 }
2600
2601 BITMAP* subBmp = 0;
2602
2603 /*
2604 if ( bitmapIndex == -1 ) {
2605 blit(bmp, sourceBitmap, sx, sy, 0, 0, dw, dh);
2606 }
2607 */
2608
2609 if(rot != 0 || mode != 0)
2610 {
2611 subBmp = script_drawing_commands.AquireSubBitmap(dw, dh);
2612
2613 if(!subBmp)
2614 {
2615 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
2616 return;
2617 }
2618 }
2619
2620
2621 dx = dx + xoffset;
2622 dy = dy + yoffset;
2623
2624 if(stretched)
2625 {
2626 if(masked) //stretched and masked
2627 {
2628 if ( rot == 0 ) //if not rotated
2629 {
2630 switch(mode)
2631 {
2632 case 1:
2633 //transparent
2634 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2635 draw_trans_sprite(bmp, subBmp, dx, dy);
2636 break;
2637
2638
2639 case 2:
2640 //pivot?
2641 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2642 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2643 //Pivoting requires two more args
2644 break;
2645
2646 case 3:
2647 //pivot + trans
2648 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2649 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2650 break;
2651
2652 case 4:
2653 //flip v
2654 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2655 draw_sprite_v_flip(bmp, subBmp, dx, dy);
2656 break;
2657
2658 case 5:
2659 //trans + v flip
2660 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2661 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
2662 break;
2663
2664 case 6:
2665 //pivot + v flip
2666 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2667 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2668 break;
2669
2670 case 8:
2671 //vlip h
2672 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2673 draw_sprite_h_flip(bmp, subBmp, dx, dy);
2674 break;
2675
2676 case 9:
2677 //trans + h flip
2678 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2679 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
2680 break;
2681
2682 case 10:
2683 //flip H and pivot
2684 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2685 //return error cannot pivot and h flip
2686 break;
2687
2688 case 12:
2689 //vh flip
2690 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2691 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
2692 break;
2693
2694 case 13:
2695 //trans + vh flip
2696 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2697 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
2698 break;
2699
2700 case 14:
2701 //pivot and vh flip
2702 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2703 //return error cannot both pivot and vh flip
2704 break;
2705
2706 case 16:
2707 //lit
2708 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2709 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
2710 break;
2711
2712 case 18:
2713 //pivot, lit
2714 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2715 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2716 break;
2717
2718 case 20:
2719 //lit + v flip
2720 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2721 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
2722 break;
2723
2724 case 22:
2725 //Pivot, vflip, lit
2726 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2727 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2728 break;
2729
2730 case 24:
2731 //lit + h flip
2732 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2733 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
2734 break;
2735
2736 case 26:
2737 //pivot + lit + hflip
2738 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
2739 //return error cannot pivot, lit, and flip
2740 break;
2741
2742 case 28:
2743 //lit + vh flip
2744 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2745 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
2746 break;
2747
2748 case 32: //gouraud
2749 //Probably not wort supporting.
2750 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2751 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
2752 break;
2753
2754 case 0:
2755 //no effect
2756 masked_stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
2757 break;
2758
2759
2760 default:
2761 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
2762
2763
2764 }
2765 } //end if not rotated
2766
2767 if ( rot != 0 ) //if rotated
2768 {
2769 switch(mode)
2770 {
2771 case 1:
2772 //transparent
2773 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2774 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2775
2776 break;
2777
2778 case 2:
2779 //pivot?
2780 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2781 //return an error, cannot both rotate and pivot
2782 break;
2783
2784 case 3:
2785 //pivot + trans
2786 //return an error, cannot both rotate and pivot
2787 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2788 break;
2789
2790 case 4:
2791 //flip v
2792 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2793 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2794 break;
2795
2796 case 5:
2797 //trans + v flip
2798 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2799 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2800 break;
2801
2802 case 6:
2803 //pivot + v flip
2804 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2805 //return an error, cannot both rotate and pivot
2806 break;
2807
2808 case 8:
2809 //flip h
2810 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
2811 //return an error, cannot both rotate and flip H
2812 break;
2813
2814 case 9:
2815 //trans + h flip
2816 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
2817 //return an error, cannot rotate and flip a trans sprite
2818 break;
2819
2820 case 10:
2821 //flip H and pivot
2822 //return error cannot pivot and h flip
2823 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2824 break;
2825
2826 case 12:
2827 //vh flip
2828 //return an error, cannot rotate and VH flip a trans sprite
2829 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
2830 break;
2831
2832 case 13:
2833 //trans + vh flip
2834 //return an error, cannot rotate and VH flip a trans sprite
2835 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
2836 break;
2837
2838 case 14:
2839 //pivot and vh flip
2840 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2841 //return error cannot both pivot and vh flip
2842 break;
2843
2844 case 16:
2845 //lit
2846 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2847 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2848 break;
2849
2850 case 18:
2851 //pivot, lit
2852 //return an error, cannot both rotate and pivot
2853 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
2854 break;
2855
2856 case 20:
2857 //lit + vflip
2858 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2859 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
2860 break;
2861
2862 case 22:
2863 //Pivot, vflip, lit
2864 //return an error, cannot both rotate and pivot
2865 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
2866 break;
2867
2868 case 24:
2869 //lit + h flip
2870 //return an error, cannot both rotate and H flip
2871 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
2872 break;
2873
2874 case 26:
2875 //pivot + lit + hflip
2876 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
2877 //return error cannot pivot, lit, and flip
2878 break;
2879
2880 case 28:
2881 //lit + vh flip
2882 //return an error, cannot both rotate and VH flip
2883 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2884 break;
2885
2886 case 32: //gouraud
2887 //Probably not wort supporting.
2888 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2889 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
2890 break;
2891
2892 case 0:
2893 //no effect.
2894 masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2895 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
2896 break;
2897
2898 default:
2899 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
2900
2901 }
2902 }
2903 } //end if stretched and masked
2904
2905 else //stretched, not masked
2906 {
2907 if ( rot == 0 ) //if not rotated
2908 {
2909 switch(mode) {
2910 case 1:
2911 //transparent
2912 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2913 draw_trans_sprite(bmp, subBmp, dx, dy);
2914 break;
2915
2916
2917 case 2:
2918 //pivot?
2919 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2920 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2921 //Pivoting requires two more args
2922 break;
2923
2924 case 3:
2925 //pivot + trans
2926 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2927 pivot_sprite_trans(bmp, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
2928 break;
2929
2930 case 4:
2931 //flip v
2932 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2933 draw_sprite_v_flip(bmp, subBmp, dx, dy);
2934 break;
2935
2936 case 5:
2937 //trans + v flip
2938 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2939 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
2940 break;
2941
2942 case 6:
2943 //pivot + v flip
2944 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2945 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
2946 break;
2947
2948 case 8:
2949 //vlip h
2950 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2951 draw_sprite_h_flip(bmp, subBmp, dx, dy);
2952 break;
2953
2954 case 9:
2955 //trans + h flip
2956 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2957 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
2958 break;
2959
2960 case 10:
2961 //flip H and pivot
2962 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
2963 //return error cannot pivot and h flip
2964 break;
2965
2966 case 12:
2967 //vh flip
2968 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2969 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
2970 break;
2971
2972 case 13:
2973 //trans + vh flip
2974 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2975 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
2976 break;
2977
2978 case 14:
2979 //pivot and vh flip
2980 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
2981 //return error cannot both pivot and vh flip
2982 break;
2983
2984 case 16:
2985 //lit
2986 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2987 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
2988 break;
2989
2990 case 18:
2991 //pivot, lit
2992 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2993 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
2994 break;
2995
2996 case 20:
2997 //lit + v flip
2998 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
2999 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3000 break;
3001
3002 case 22:
3003 //Pivot, vflip, lit
3004 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3005 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3006 break;
3007
3008 case 24:
3009 //lit + h flip
3010 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3011 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3012 break;
3013
3014 case 26:
3015 //pivot + lit + hflip
3016 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3017 //return error cannot pivot, lit, and flip
3018 break;
3019
3020 case 28:
3021 //lit + vh flip
3022 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3023 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3024 break;
3025
3026 case 32: //gouraud
3027 //Probably not wort supporting.
3028 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3029 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3030 break;
3031
3032 case 0:
3033 //no effect
3034 stretch_blit(sourceBitmap, bmp, sx, sy, sw, sh, dx, dy, dw, dh);
3035 break;
3036
3037
3038 default:
3039 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3040
3041
3042 }
3043 } //end if not rotated
3044
3045 if ( rot != 0 ) //if rotated
3046 {
3047 switch(mode)
3048 {
3049 case 1:
3050 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3051 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3052
3053 break;
3054
3055 case 2:
3056 //pivot?
3057 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3058 //return an error, cannot both rotate and pivot
3059 break;
3060
3061 case 3:
3062 //pivot + trans
3063 //return an error, cannot both rotate and pivot
3064 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3065 break;
3066
3067 case 4:
3068 //flip v
3069 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3070 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3071 break;
3072
3073 case 5:
3074 //trans + v flip
3075 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3076 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3077 break;
3078
3079 case 6:
3080 //pivot + v flip
3081 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3082 //return an error, cannot both rotate and pivot
3083 break;
3084
3085 case 8:
3086 //flip h
3087 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3088 //return an error, cannot both rotate and flip H
3089 break;
3090
3091 case 9:
3092 //trans + h flip
3093 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3094 //return an error, cannot rotate and flip a trans sprite
3095 break;
3096
3097 case 10:
3098 //flip H and pivot
3099 //return error cannot pivot and h flip
3100 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3101 break;
3102
3103 case 12:
3104 //vh flip
3105 //return an error, cannot rotate and VH flip a trans sprite
3106 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3107 break;
3108
3109 case 13:
3110 //trans + vh flip
3111 //return an error, cannot rotate and VH flip a trans sprite
3112 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3113 break;
3114
3115 case 14:
3116 //pivot and vh flip
3117 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3118 //return error cannot both pivot and vh flip
3119 break;
3120
3121 case 16:
3122 //lit
3123 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3124 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3125 break;
3126
3127 case 18:
3128 //pivot, lit
3129 //return an error, cannot both rotate and pivot
3130 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3131 break;
3132
3133 case 20:
3134 //lit + vflip
3135 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
3136 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3137 break;
3138
3139 case 22:
3140 //Pivot, vflip, lit
3141 //return an error, cannot both rotate and pivot
3142 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3143 break;
3144
3145 case 24:
3146 //lit + h flip
3147 //return an error, cannot both rotate and H flip
3148 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3149 break;
3150
3151 case 26:
3152 //pivot + lit + hflip
3153 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3154 //return error cannot pivot, lit, and flip
3155 break;
3156
3157 case 28:
3158 //lit + vh flip
3159 //return an error, cannot both rotate and VH flip
3160 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3161 break;
3162
3163 case 32: //gouraud
3164 //Probably not wort supporting.
3165 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3166 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3167 break;
3168
3169 case 0:
3170 //no effect.
3171 stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3172 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3173 break;
3174
3175 default:
3176 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3177
3178 }
3179 }
3180
3181 } //end if stretched, but not masked
3182 }
3183 else //not stretched
3184 {
3185
3186 if(masked) //if masked, but not stretched
3187 {
3188
3189 if ( rot == 0 ) //if not rotated
3190 {
3191 switch(mode)
3192 {
3193 case 1:
3194 //transparent
3195 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3196 draw_trans_sprite(bmp, subBmp, dx, dy);
3197 break;
3198
3199
3200 case 2:
3201 //pivot?
3202 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3203 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3204 //Pivoting requires two more args
3205 break;
3206
3207 case 3:
3208 //pivot + trans
3209 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3210 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3211 break;
3212
3213 case 4:
3214 //flip v
3215 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3216 draw_sprite_v_flip(bmp, subBmp, dx, dy);
3217 break;
3218
3219 case 5:
3220 //trans + v flip
3221 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3222 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
3223 break;
3224
3225 case 6:
3226 //pivot + v flip
3227 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3228 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3229 break;
3230
3231 case 8:
3232 //vlip h
3233 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3234 draw_sprite_h_flip(bmp, subBmp, dx, dy);
3235 break;
3236
3237 case 9:
3238 //trans + h flip
3239 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3240 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
3241 break;
3242
3243 case 10:
3244 //flip H and pivot
3245 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3246 //return error cannot pivot and h flip
3247 break;
3248
3249 case 12:
3250 //vh flip
3251 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3252 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
3253 break;
3254
3255 case 13:
3256 //trans + vh flip
3257 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3258 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
3259 break;
3260
3261 case 14:
3262 //pivot and vh flip
3263 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3264 //return error cannot both pivot and vh flip
3265 break;
3266
3267 case 16:
3268 //lit
3269 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3270 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
3271 break;
3272
3273 case 18:
3274 //pivot, lit
3275 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3276 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3277 break;
3278
3279 case 20:
3280 //lit + v flip
3281 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3282 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3283 break;
3284
3285 case 22:
3286 //Pivot, vflip, lit
3287 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3288 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3289 break;
3290
3291 case 24:
3292 //lit + h flip
3293 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3294 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3295 break;
3296
3297 case 26:
3298 //pivot + lit + hflip
3299 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3300 //return error cannot pivot, lit, and flip
3301 break;
3302
3303 case 28:
3304 //lit + vh flip
3305 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3306 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3307 break;
3308
3309 case 32: //gouraud
3310 //Probably not wort supporting.
3311 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3312 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3313 break;
3314
3315 case 0:
3316 //no effect
3317 masked_blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
3318 break;
3319
3320
3321 default:
3322 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3323
3324
3325 }
3326 } //end if not rotated
3327
3328 if ( rot != 0 ) //if rotated
3329 {
3330 switch(mode)
3331 {
3332 case 1:
3333 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); //transparent
3334 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3335
3336 break;
3337
3338 case 2:
3339 //pivot?
3340 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3341 //return an error, cannot both rotate and pivot
3342 break;
3343
3344 case 3:
3345 //pivot + trans
3346 //return an error, cannot both rotate and pivot
3347 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3348 break;
3349
3350 case 4:
3351 //flip v
3352 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3353 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3354 break;
3355
3356 case 5:
3357 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
3358 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3359 break;
3360
3361 case 6:
3362 //pivot + v flip
3363 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3364 //return an error, cannot both rotate and pivot
3365 break;
3366
3367 case 8:
3368 //flip h
3369 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3370 //return an error, cannot both rotate and flip H
3371 break;
3372
3373 case 9:
3374 //trans + h flip
3375 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3376 //return an error, cannot rotate and flip a trans sprite
3377 break;
3378
3379 case 10:
3380 //flip H and pivot
3381 //return error cannot pivot and h flip
3382 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3383 break;
3384
3385 case 12:
3386 //vh flip
3387 //return an error, cannot rotate and VH flip a trans sprite
3388 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3389 break;
3390
3391 case 13:
3392 //trans + vh flip
3393 //return an error, cannot rotate and VH flip a trans sprite
3394 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3395 break;
3396
3397 case 14:
3398 //pivot and vh flip
3399 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3400 //return error cannot both pivot and vh flip
3401 break;
3402
3403 case 16:
3404 //lit
3405 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3406 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3407 break;
3408
3409 case 18:
3410 //pivot, lit
3411 //return an error, cannot both rotate and pivot
3412 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3413 break;
3414
3415 case 20:
3416 //lit + vflip
3417 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3418 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3419 break;
3420
3421 case 22:
3422 //Pivot, vflip, lit
3423 //return an error, cannot both rotate and pivot
3424 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3425 break;
3426
3427 case 24:
3428 //lit + h flip
3429 //return an error, cannot both rotate and H flip
3430 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3431 break;
3432
3433 case 26:
3434 //pivot + lit + hflip
3435 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3436 //return error cannot pivot, lit, and flip
3437 break;
3438
3439 case 28:
3440 //lit + vh flip
3441 //return an error, cannot both rotate and VH flip
3442 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3443 break;
3444
3445 case 32: //gouraud
3446 //Probably not wort supporting.
3447 //stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
3448 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3449 break;
3450
3451 case 0:
3452 //no effect.
3453 masked_blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3454 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3455 break;
3456
3457 default:
3458 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3459
3460 }
3461 } //end rtated, masked
3462 } //end if masked
3463
3464 else //not masked, and not stretched; just blit
3465 {
3466
3467 if ( rot == 0 ) //if not rotated
3468 {
3469 switch(mode)
3470 {
3471 case 1:
3472 //transparent
3473 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3474 draw_trans_sprite(bmp, subBmp, dx, dy);
3475 break;
3476
3477
3478 case 2:
3479 //pivot?
3480 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3481 pivot_sprite(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3482 //Pivoting requires two more args
3483 break;
3484
3485 case 3:
3486 //pivot + trans
3487 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3488 pivot_sprite_trans(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3489 break;
3490
3491 case 4:
3492 //flip v
3493 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3494 draw_sprite_v_flip(bmp, subBmp, dx, dy);
3495 break;
3496
3497 case 5:
3498 //trans + v flip
3499 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3500 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
3501 break;
3502
3503 case 6:
3504 //pivot + v flip
3505 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3506 pivot_sprite_v_flip(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
3507 break;
3508
3509 case 8:
3510 //vlip h
3511 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3512 draw_sprite_h_flip(bmp, subBmp, dx, dy);
3513 break;
3514
3515 case 9:
3516 //trans + h flip
3517 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3518 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
3519 break;
3520
3521 case 10:
3522 //flip H and pivot
3523 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3524 //return error cannot pivot and h flip
3525 break;
3526
3527 case 12:
3528 //vh flip
3529 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3530 draw_sprite_vh_flip(bmp, subBmp, dx, dy);
3531 break;
3532
3533 case 13:
3534 //trans + vh flip
3535 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3536 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
3537 break;
3538
3539 case 14:
3540 //pivot and vh flip
3541 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3542 //return error cannot both pivot and vh flip
3543 break;
3544
3545 case 16:
3546 //lit
3547 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3548 draw_lit_sprite(bmp, subBmp, dx, dy, litcolour);
3549 break;
3550
3551 case 18:
3552 //pivot, lit
3553 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3554 pivot_sprite_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3555 break;
3556
3557 case 20:
3558 //lit + v flip
3559 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3560 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
3561 break;
3562
3563 case 22:
3564 //Pivot, vflip, lit
3565 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3566 pivot_sprite_v_flip_lit(bmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
3567 break;
3568
3569 case 24:
3570 //lit + h flip
3571 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3572 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
3573 break;
3574
3575 case 26:
3576 //pivot + lit + hflip
3577 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
3578 //return error cannot pivot, lit, and flip
3579 break;
3580
3581 case 28:
3582 //lit + vh flip
3583 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3584 draw_sprite_ex(bmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
3585 break;
3586
3587 case 32: //gouraud
3588 //Probably not wort supporting.
3589 //blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3590 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3591 break;
3592
3593 case 0:
3594 //no effect
3595 blit(sourceBitmap, bmp, sx, sy, dx, dy, dw, dh);
3596 break;
3597
3598
3599 default:
3600 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3601
3602
3603 }
3604 } //end if not rotated
3605
3606 if ( rot != 0 ) //if rotated
3607 {
3608 switch(mode)
3609 {
3610 case 1:
3611 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);//transparent
3612 rotate_sprite_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3613
3614 break;
3615
3616 case 2:
3617 //pivot?
3618 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3619 //return an error, cannot both rotate and pivot
3620 break;
3621
3622 case 3:
3623 //pivot + trans
3624 //return an error, cannot both rotate and pivot
3625 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3626 break;
3627
3628 case 4:
3629 //flip v
3630 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3631 rotate_sprite_v_flip(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3632 break;
3633
3634 case 5:
3635 //trans + v flip
3636 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3637 rotate_sprite_v_flip_trans(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3638 break;
3639
3640 case 6:
3641 //pivot + v flip
3642 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3643 //return an error, cannot both rotate and pivot
3644 break;
3645
3646 case 8:
3647 //flip h
3648 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
3649 //return an error, cannot both rotate and flip H
3650 break;
3651
3652 case 9:
3653 //trans + h flip
3654 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
3655 //return an error, cannot rotate and flip a trans sprite
3656 break;
3657
3658 case 10:
3659 //flip H and pivot
3660 //return error cannot pivot and h flip
3661 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
3662 break;
3663
3664 case 12:
3665 //vh flip
3666 //return an error, cannot rotate and VH flip a trans sprite
3667 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3668 break;
3669
3670 case 13:
3671 //trans + vh flip
3672 //return an error, cannot rotate and VH flip a trans sprite
3673 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
3674 break;
3675
3676 case 14:
3677 //pivot and vh flip
3678 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3679 //return error cannot both pivot and vh flip
3680 break;
3681
3682 case 16:
3683 //lit
3684 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3685 rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3686 break;
3687
3688 case 18:
3689 //pivot, lit
3690 //return an error, cannot both rotate and pivot
3691 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
3692 break;
3693
3694 case 20:
3695 //lit + vflip
3696 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3697 rotate_sprite_v_flip_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
3698 break;
3699
3700 case 22:
3701 //Pivot, vflip, lit
3702 //return an error, cannot both rotate and pivot
3703 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
3704 break;
3705
3706 case 24:
3707 //lit + h flip
3708 //return an error, cannot both rotate and H flip
3709 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
3710 break;
3711
3712 case 26:
3713 //pivot + lit + hflip
3714 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
3715 //return error cannot pivot, lit, and flip
3716 break;
3717
3718 case 28:
3719 //lit + vh flip
3720 //return an error, cannot both rotate and VH flip
3721 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
3722 break;
3723
3724 case 32: //gouraud
3725 //Probably not wort supporting.
3726 //blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3727 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
3728 break;
3729
3730 case 0:
3731 //no effect.
3732 blit(sourceBitmap, subBmp, sx, sy, 0, 0, dw, dh);
3733 rotate_sprite(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
3734 break;
3735
3736 default:
3737 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
3738
3739 }
3740 } //end if rotated
3741 } //end if not masked
3742 } //end if not stretched
3743
3744 //cleanup
3745 if(subBmp)
3746 {
3747 script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
3748 }
3749 }
3750
3751
3752 void do_drawquad3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3753 {
3754 //sdci[1]=layer
3755 //sdci[2]=pos[12]
3756 //sdci[3]=uv[8]
3757 //sdci[4]=color[4]
3758 //sdci[5]=size[2]
3759 //sdci[6]=flip
3760 //sdci[7]=tile/combo
3761 //sdci[8]=polytype
3762
3763 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
3764
3765 if(!v_ptr)
3766 {
3767 al_trace("Quad3d: Vector pointer is null! Internal error. \n");
3768 return;
3769 }
3770
3771 std::vector<int32_t> &v = *v_ptr;
3772
3773 if(v.empty())
3774 return;
3775
3776 int32_t* pos = &v[0];
3777 int32_t* uv = &v[12];
3778 int32_t* col = &v[20];
3779 int32_t* size = &v[24];
3780
3781 int32_t w = size[0]; //magic numerical constants... yuck.
3782 int32_t h = size[1];
3783 int32_t flip = (sdci[6]/10000)&3;
3784 int32_t tile = sdci[7]/10000;
3785 int32_t polytype = sdci[8]/10000;
3786
3787 polytype = vbound(polytype, 0, 14);
3788
3789 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
3790 {
3791 Z_message("Quad3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
3792 return; //non power of two error
3793 }
3794
3795 int32_t tex_width = w*16;
3796 int32_t tex_height = h*16;
3797
3798 bool mustDestroyBmp = false;
3799 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
3800
3801 if(!tex)
3802 {
3803 mustDestroyBmp = true;
3804 tex = create_bitmap_ex(8, tex_width, tex_height);
3805 clear_bitmap(tex);
3806 }
3807
3808 if(tile > 0) // TILE
3809 {
3810 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
3811 }
3812 else // COMBO
3813 {
3814 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
3815 const int32_t tiletodraw = combo_tile(c, 0, 0);
3816 flip = flip ^ c.flip;
3817
3818 if(!(c.animflags & AF_EDITOR_ONLY))
3819 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
3820 }
3821
3822 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
3823 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
3824 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
3825 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
3826
3827 quad3d_f(bmp, polytype, tex, &V1, &V2, &V3, &V4);
3828
3829 if(mustDestroyBmp)
3830 destroy_bitmap(tex);
3831
3832 }
3833
3834
3835
3836 void do_drawtriangle3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3837 {
3838 //sdci[1]=layer
3839 //sdci[2]=pos[9]
3840 //sdci[3]=uv[6]
3841 //sdci[4]=color[3]
3842 //sdci[5]=size[2]
3843 //sdci[6]=flip
3844 //sdci[7]=tile/combo
3845 //sdci[8]=polytype
3846
3847 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
3848
3849 if(!v_ptr)
3850 {
3851 al_trace("Triange3d: Vector pointer is null! Internal error. \n");
3852 return;
3853 }
3854
3855 std::vector<int32_t> &v = *v_ptr;
3856
3857 if(v.empty())
3858 return;
3859
3860 int32_t* pos = &v[0];
3861 int32_t* uv = &v[9];
3862 int32_t* col = &v[15];
3863 int32_t* size = &v[18];
3864
3865 int32_t w = size[0]; //magic numerical constants... yuck.
3866 int32_t h = size[1];
3867 int32_t flip = (sdci[6]/10000)&3;
3868 int32_t tile = sdci[7]/10000;
3869 int32_t polytype = sdci[8]/10000;
3870
3871 polytype = vbound(polytype, 0, 14);
3872
3873 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
3874 {
3875 Z_message("Triangle3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
3876 return; //non power of two error
3877 }
3878
3879 int32_t tex_width = w*16;
3880 int32_t tex_height = h*16;
3881
3882 bool mustDestroyBmp = false;
3883 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
3884
3885 if(!tex)
3886 {
3887 mustDestroyBmp = true;
3888 tex = create_bitmap_ex(8, tex_width, tex_height);
3889 clear_bitmap(tex);
3890 }
3891
3892 if(tile > 0) // TILE
3893 {
3894 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
3895 }
3896 else // COMBO
3897 {
3898 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
3899 const int32_t tiletodraw = combo_tile(c, 0, 0);
3900 flip = flip ^ c.flip;
3901
3902 if(!(c.animflags & AF_EDITOR_ONLY))
3903 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
3904 }
3905
3906 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
3907 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
3908 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
3909
3910 triangle3d_f(bmp, polytype, tex, &V1, &V2, &V3);
3911
3912 if(mustDestroyBmp)
3913 destroy_bitmap(tex);
3914
3915 }
3916
3917 12431 void bmp_do_rectr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
3918 {
3919 //Z_scripterrlog("rect sdci[13] is: %d\n", sdci[13]);
3920 //sdci[1]=layer
3921 //sdci[2]=x
3922 //sdci[3]=y
3923 //sdci[4]=x2
3924 //sdci[5]=y2
3925 //sdci[6]=color
3926 //sdci[7]=scale factor
3927 //sdci[8]=rotation anchor x
3928 //sdci[9]=rotation anchor y
3929 //sdci[10]=rotation angle
3930 //sdci[11]=fill
3931 //sdci[12]=opacity
3932 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
3933
1/2
✓ Branch 0 taken 12431 times.
✗ Branch 1 not taken.
12431 if(sdci[7]==0) //scale
3934 {
3935 return;
3936 }
3937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12431 times.
12431 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
3938 {
3939 Z_scripterrlog("bitmap->Rectangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
3940 return;
3941 }
3942 12431 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
3943
1/2
✓ Branch 0 taken 12431 times.
✗ Branch 1 not taken.
12431 if ( refbmp == NULL ) return;
3944
3945
2/4
✓ Branch 0 taken 12431 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12431 times.
12431 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
3946
3947 12431 int32_t x1=sdci[2]/10000;
3948 12431 int32_t y1=sdci[3]/10000;
3949 12431 int32_t x2=sdci[4]/10000;
3950 12431 int32_t y2=sdci[5]/10000;
3951
3952
3953
2/2
✓ Branch 0 taken 12427 times.
✓ Branch 1 taken 4 times.
12431 if(x1>x2)
3954 {
3955 4 zc_swap(x1,x2);
3956 4 }
3957
3958
2/2
✓ Branch 0 taken 11147 times.
✓ Branch 1 taken 1284 times.
12431 if(y1>y2)
3959 {
3960 1284 zc_swap(y1,y2);
3961 1284 }
3962
3963
2/2
✓ Branch 0 taken 11151 times.
✓ Branch 1 taken 1280 times.
12431 if(sdci[7] != 10000)
3964 {
3965 1280 int32_t w=x2-x1+1;
3966 1280 int32_t h=y2-y1+1;
3967 1280 int32_t w2=(w*sdci[7])/10000;
3968 1280 int32_t h2=(h*sdci[7])/10000;
3969 1280 x1=x1-((w2-w)/2);
3970 1280 x2=x2+((w2-w)/2);
3971 1280 y1=y1-((h2-h)/2);
3972 1280 y2=y2+((h2-h)/2);
3973 1280 }
3974
3975 12431 int32_t color=sdci[6]/10000;
3976
3977
2/2
✓ Branch 0 taken 12303 times.
✓ Branch 1 taken 128 times.
12431 if(sdci[12]/10000<=127) //translucent
3978 {
3979 128 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
3980 128 }
3981
3982
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 12335 times.
12431 if(sdci[10]==0) //no rotation
3983 {
3984
2/2
✓ Branch 0 taken 9143 times.
✓ Branch 1 taken 3192 times.
12335 if(sdci[11]) //filled
3985 {
3986 9143 rectfill(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
3987 9143 }
3988 else //outline
3989 {
3990 3192 rect(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
3991 }
3992 12335 }
3993 else //rotate
3994 {
3995 int32_t xy[16];
3996 96 int32_t rx=sdci[8]/10000;
3997 96 int32_t ry=sdci[9]/10000;
3998 96 fixed ra1=itofix(sdci[10]%10000)/10000;
3999 96 fixed ra2=itofix(sdci[10]/10000);
4000 96 fixed ra=ra1+ra2;
4001 96 ra = (ra/360)*256;
4002
4003 96 fixed fcosa = fixcos(ra);
4004 96 fixed fsina = fixsin(ra);
4005
4006 96 xy[ 0]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry))); //x1
4007 96 xy[ 1]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry))); //y1
4008 96 xy[ 2]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y1 - ry))); //x2
4009 96 xy[ 3]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y1 - ry))); //y1
4010 96 xy[ 4]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry))); //x2
4011 96 xy[ 5]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry))); //y2
4012 96 xy[ 6]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y2 - ry))); //x1
4013 96 xy[ 7]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y2 - ry))); //y2
4014 96 xy[ 8]=xoffset+rx + fixtoi((fcosa * (x1 - rx) - fsina * (y1 - ry + 1))); //x1
4015 96 xy[ 9]=yoffset+ry + fixtoi((fsina * (x1 - rx) + fcosa * (y1 - ry + 1))); //y1
4016 96 xy[10]=xoffset+rx + fixtoi((fcosa * (x2 - rx - 1) - fsina * (y1 - ry))); //x2
4017 96 xy[11]=yoffset+ry + fixtoi((fsina * (x2 - rx - 1) + fcosa * (y1 - ry))); //y1
4018 96 xy[12]=xoffset+rx + fixtoi((fcosa * (x2 - rx) - fsina * (y2 - ry - 1))); //x2
4019 96 xy[13]=yoffset+ry + fixtoi((fsina * (x2 - rx) + fcosa * (y2 - ry - 1))); //y2
4020 96 xy[14]=xoffset+rx + fixtoi((fcosa * (x1 - rx + 1) - fsina * (y2 - ry))); //x1
4021 96 xy[15]=yoffset+ry + fixtoi((fsina * (x1 - rx + 1) + fcosa * (y2 - ry))); //y2
4022
4023
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(sdci[11]) //filled
4024 {
4025 96 polygon(refbmp, 4, xy, color);
4026 96 }
4027 else //outline
4028 {
4029 line(refbmp, xy[0], xy[1], xy[10], xy[11], color);
4030 line(refbmp, xy[2], xy[3], xy[12], xy[13], color);
4031 line(refbmp, xy[4], xy[5], xy[14], xy[15], color);
4032 line(refbmp, xy[6], xy[7], xy[ 8], xy[ 9], color);
4033 }
4034 }
4035
4036 12431 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4037 12431 }
4038
4039 void bmp_do_framer(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4040 {
4041 //sdci[1]=layer
4042 //sdci[2]=x
4043 //sdci[3]=y
4044 //sdci[4]=tile
4045 //sdci[5]=cset
4046 //sdci[6]=width
4047 //sdci[7]=height
4048 //sdci[8]=overlay
4049 //sdci[9]=opacity
4050
4051 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4052 {
4053 Z_scripterrlog("bitmap->DrawFrame() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4054 return;
4055 }
4056 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4057 if ( refbmp == NULL ) return;
4058
4059 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4060
4061 int32_t x=sdci[2]/10000;
4062 int32_t y=sdci[3]/10000;
4063
4064 int32_t tile=sdci[4]/10000;
4065 int32_t cs=sdci[5]/10000;
4066 int32_t w=sdci[6]/10000;
4067 int32_t h=sdci[7]/10000;
4068 bool overlay=sdci[8];
4069 bool trans=(sdci[9]/10000<=127);
4070
4071 frame2x2(refbmp, x + xoffset, y + yoffset, tile, cs, w, h, 0, overlay, trans);
4072 }
4073
4074
4075 192290 void bmp_do_circler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4076 {
4077 //sdci[1]=layer
4078 //sdci[2]=x
4079 //sdci[3]=y
4080 //sdci[4]=radius
4081 //sdci[5]=color
4082 //sdci[6]=scale factor
4083 //sdci[7]=rotation anchor x
4084 //sdci[8]=rotation anchor y
4085 //sdci[9]=rotation angle
4086 //sdci[10]=fill
4087 //sdci[11]=opacity
4088 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4089
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[6]==0) //scale
4090 {
4091 return;
4092 }
4093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192290 times.
192290 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4094 {
4095 Z_scripterrlog("bitmap->Circle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4096 return;
4097 }
4098 192290 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4099
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if ( refbmp == NULL ) return;
4100
4101
2/4
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 192290 times.
192290 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4102
4103 192290 int32_t x1=sdci[2]/10000;
4104 192290 int32_t y1=sdci[3]/10000;
4105 192290 qword r=sdci[4];
4106
4107
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[6] != 10000)
4108 {
4109 r*=sdci[6];
4110 r/=10000;
4111 }
4112
4113 192290 r/=10000;
4114 192290 int32_t color=sdci[5]/10000;
4115
4116
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[11]/10000<=127) //translucent
4117 {
4118 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4119 }
4120
4121
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 192290 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
192290 if(sdci[9]!=0&&(sdci[2]!=sdci[7]||sdci[3]!=sdci[8])) //rotation
4122 {
4123 int32_t xy[2];
4124 int32_t rx=sdci[7]/10000;
4125 int32_t ry=sdci[8]/10000;
4126 fixed ra1=itofix(sdci[9]%10000)/10000;
4127 fixed ra2=itofix(sdci[9]/10000);
4128 fixed ra=ra1+ra2;
4129 ra = (ra/360)*256;
4130
4131 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4132 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4133 x1=xy[0];
4134 y1=xy[1];
4135 }
4136
4137
1/2
✓ Branch 0 taken 192290 times.
✗ Branch 1 not taken.
192290 if(sdci[10]) //filled
4138 {
4139 192290 circlefill(refbmp, x1+xoffset, y1+yoffset, r, color);
4140 192290 }
4141 else //outline
4142 {
4143 circle(refbmp, x1+xoffset, y1+yoffset, r, color);
4144 }
4145
4146 192290 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4147 192290 }
4148
4149
4150 void bmp_do_arcr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4151 {
4152 //sdci[1]=layer
4153 //sdci[2]=x
4154 //sdci[3]=y
4155 //sdci[4]=radius
4156 //sdci[5]=start angle
4157 //sdci[6]=end angle
4158 //sdci[7]=color
4159 //sdci[8]=scale factor
4160 //sdci[9]=rotation anchor x
4161 //sdci[10]=rotation anchor y
4162 //sdci[11]=rotation angle
4163 //sdci[12]=closed
4164 //sdci[13]=fill
4165 //sdci[14]=opacity
4166 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4167
4168 if(sdci[8]==0) //scale
4169 {
4170 return;
4171 }
4172 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4173 {
4174 Z_scripterrlog("bitmap->Arc() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4175 return;
4176 }
4177 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4178 if ( refbmp == NULL ) return;
4179
4180 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4181
4182 int32_t cx=sdci[2]/10000;
4183 int32_t cy=sdci[3]/10000;
4184 qword r=sdci[4];
4185
4186 if(sdci[8] != 10000)
4187 {
4188 r*=sdci[8];
4189 r/=10000;
4190 }
4191
4192 r/=10000;
4193
4194 int32_t color=sdci[7]/10000;
4195
4196 fixed ra1=itofix(sdci[11]%10000)/10000;
4197 fixed ra2=itofix(sdci[11]/10000);
4198 fixed ra=ra1+ra2;
4199 ra = (ra/360)*256;
4200
4201
4202 fixed a1=itofix(sdci[5]%10000)/10000;
4203 fixed a2=itofix(sdci[5]/10000);
4204 fixed sa=a1+a2;
4205 sa = (sa/360)*256;
4206
4207 a1=itofix(sdci[6]%10000)/10000;
4208 a2=itofix(sdci[6]/10000);
4209 fixed ea=a1+a2;
4210 ea = (ea/360)*256;
4211
4212 if(sdci[11]!=0) //rotation
4213 {
4214 int32_t rx=sdci[9]/10000;
4215 int32_t ry=sdci[10]/10000;
4216
4217 cx=rx + fixtoi((fixcos(ra) * (cx - rx) - fixsin(ra) * (cy - ry))); //x1
4218 cy=ry + fixtoi((fixsin(ra) * (cx - rx) + fixcos(ra) * (cy - ry))); //y1
4219 ea-=ra;
4220 sa-=ra;
4221 }
4222
4223 int32_t fx=cx+fixtoi(fixcos(-(ea+sa)/2)*r/2);
4224 int32_t fy=cy+fixtoi(fixsin(-(ea+sa)/2)*r/2);
4225
4226 if(sdci[12]) //closed
4227 {
4228 if(sdci[13]) //filled
4229 {
4230 clear_bitmap(prim_bmp);
4231 arc(prim_bmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4232 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
4233 line(prim_bmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
4234 int fillx = zc_max(0,fx)+xoffset;
4235 int filly = zc_max(0,fy)+yoffset;
4236 zprint2("bitmap->Arc fill at prim_bmp (%d,%d) - 512x512\n", fillx, filly);
4237 floodfill(prim_bmp, fillx, filly, color);
4238
4239 if(sdci[14]/10000<=127) //translucent
4240 {
4241 draw_trans_sprite(refbmp, prim_bmp, 0,0);
4242 }
4243 else
4244 {
4245 draw_sprite(refbmp, prim_bmp, 0,0);
4246 }
4247 }
4248 else
4249 {
4250 arc(refbmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4251 line(refbmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-sa)*r), cy+yoffset+fixtoi(fixsin(-sa)*r), color);
4252 line(refbmp, cx+xoffset, cy+yoffset, cx+xoffset+fixtoi(fixcos(-ea)*r), cy+yoffset+fixtoi(fixsin(-ea)*r), color);
4253 }
4254 }
4255 else
4256 {
4257 if(sdci[14]/10000<=127) //translucent
4258 {
4259 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4260 }
4261
4262 arc(refbmp, cx+xoffset, cy+yoffset, sa, ea, int32_t(r), color);
4263 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4264 }
4265 }
4266
4267
4268 502 void bmp_do_ellipser(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4269 {
4270 //sdci[1]=layer
4271 //sdci[2]=x
4272 //sdci[3]=y
4273 //sdci[4]=radiusx
4274 //sdci[5]=radiusy
4275 //sdci[6]=color
4276 //sdci[7]=scale factor
4277 //sdci[8]=rotation anchor x
4278 //sdci[9]=rotation anchor y
4279 //sdci[10]=rotation angle
4280 //sdci[11]=fill
4281 //sdci[12]=opacity
4282 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4283
4284
1/2
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
502 if(sdci[7]==0) //scale
4285 {
4286 return;
4287 }
4288
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 502 times.
502 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4289 {
4290 Z_scripterrlog("bitmap->Ellipse() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4291 return;
4292 }
4293 502 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4294
1/2
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
502 if ( refbmp == NULL ) return;
4295
4296 502 int32_t x1=sdci[2]/10000;
4297 502 int32_t y1=sdci[3]/10000;
4298 502 int32_t radx=sdci[4]/10000;
4299 502 radx*=sdci[7]/10000;
4300 502 int32_t rady=sdci[5]/10000;
4301 502 rady*=sdci[7]/10000;
4302 502 int32_t color=sdci[6]/10000;
4303 502 float rotation = sdci[10]/10000;
4304
4305 502 int32_t rx=sdci[8]/10000;
4306 502 int32_t ry=sdci[9]/10000;
4307 502 fixed ra1=itofix(sdci[10]%10000)/10000;
4308 502 fixed ra2=itofix(sdci[10]/10000);
4309 502 fixed ra=ra1+ra2;
4310 502 ra = (ra/360)*256;
4311
4312
2/4
✓ Branch 0 taken 502 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 502 times.
✗ Branch 3 not taken.
502 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4313
4314 int32_t xy[2];
4315 502 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4316 502 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4317 502 x1=xy[0];
4318 502 y1=xy[1];
4319
4320
6/8
✓ Branch 0 taken 498 times.
✓ Branch 1 taken 4 times.
✓ Branch 2 taken 494 times.
✓ Branch 3 taken 4 times.
✓ Branch 4 taken 494 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 494 times.
502 if(radx<1||rady<1||radx>255||rady>255) return;
4321
4322 494 BITMAP* bitty = script_drawing_commands.AquireSubBitmap(radx*2+1, rady*2+1);
4323
4324
2/4
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 494 times.
494 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4325
4326
1/2
✓ Branch 0 taken 494 times.
✗ Branch 1 not taken.
494 if(sdci[11]) //filled
4327 {
4328
4329
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 494 times.
494 if(sdci[12]/10000<128) //translucent
4330 {
4331 clear_bitmap(prim_bmp);
4332 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
4333 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4334 draw_trans_sprite(refbmp, prim_bmp, 0, 0);
4335 }
4336 else // no opacity
4337 {
4338
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 62 times.
494 ellipsefill(bitty, radx, rady, radx, rady, color==0?255:color);
4339 494 rotate_sprite(refbmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4340 }
4341 494 }
4342 else //not filled
4343 {
4344 if(sdci[12]/10000<128) //translucent
4345 {
4346 clear_bitmap(prim_bmp);
4347 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
4348 rotate_sprite(prim_bmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4349 draw_trans_sprite(refbmp, prim_bmp, 0, 0);
4350 }
4351 else // no opacity
4352 {
4353 ellipse(bitty, radx, rady, radx, rady, color==0?255:color);
4354 rotate_sprite(refbmp, bitty, x1+xoffset-radx,y1+yoffset-rady, degrees_to_fixed(rotation));
4355 }
4356 }
4357
4358 // Since 0 is the transparent color, the stuff above will fail if the ellipse color is also 0.
4359 // Instead, it uses color 255 and replaces it afterward. That'll also screw up color 255 around
4360 // the ellipse, but it shouldn't be used anyway.
4361
2/2
✓ Branch 0 taken 432 times.
✓ Branch 1 taken 62 times.
494 if(color==0)
4362 {
4363 // This is very slow, so check the smallest possible square
4364
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
62 int32_t endx=zc_min(bmp->w-1, x1+zc_max(radx, rady));
4365
3/6
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 62 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 62 times.
62 int32_t endy=zc_min(bmp->h-1, y1+zc_max(radx, rady));
4366
4367
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 62 times.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2 times.
✓ Branch 6 taken 4430 times.
✓ Branch 7 taken 62 times.
4492 for(int32_t y=zc_max(0, y1-zc_max(radx, rady)); y<=endy; y++)
4368
6/8
✗ Branch 0 not taken.
✓ Branch 1 taken 4430 times.
✓ Branch 2 taken 1086 times.
✓ Branch 3 taken 3344 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1086 times.
✓ Branch 6 taken 467774 times.
✓ Branch 7 taken 4430 times.
472204 for(int32_t x=zc_max(0, x1-zc_max(radx, rady)); x<=endx; x++)
4369
2/2
✓ Branch 0 taken 238992 times.
✓ Branch 1 taken 228782 times.
696556 if(getpixel(refbmp, x, y)==255)
4370 233212 putpixel(refbmp, x, y, 0);
4371 62 }
4372
4373 494 script_drawing_commands.ReleaseSubBitmap(bitty);
4374 502 }
4375
4376
4377 144 void bmp_do_liner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4378 {
4379 //sdci[1]=layer
4380 //sdci[2]=x
4381 //sdci[3]=y
4382 //sdci[4]=x2
4383 //sdci[5]=y2
4384 //sdci[6]=color
4385 //sdci[7]=scale factor
4386 //sdci[8]=rotation anchor x
4387 //sdci[9]=rotation anchor y
4388 //sdci[10]=rotation angle
4389 //sdci[11]=opacity
4390 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4391
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[7]==0) //scale
4392 {
4393 return;
4394 }
4395
4396
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144 times.
144 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4397 {
4398 Z_scripterrlog("bitmap->Line() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4399 return;
4400 }
4401
4402 144 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4403
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if ( refbmp == NULL ) return;
4404
4405 144 int32_t x1=sdci[2]/10000;
4406 144 int32_t y1=sdci[3]/10000;
4407 144 int32_t x2=sdci[4]/10000;
4408 144 int32_t y2=sdci[5]/10000;
4409
4410
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[7] != 10000)
4411 {
4412 int32_t w=x2-x1+1;
4413 int32_t h=y2-y1+1;
4414 int32_t w2=int32_t(w*((double)sdci[7]/10000.0));
4415 int32_t h2=int32_t(h*((double)sdci[7]/10000.0));
4416 x1=x1-((w2-w)/2);
4417 x2=x2+((w2-w)/2);
4418 y1=y1-((h2-h)/2);
4419 y2=y2+((h2-h)/2);
4420 }
4421
4422 144 int32_t color=sdci[6]/10000;
4423
4424
2/4
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 144 times.
144 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4425
4426
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[11]/10000<=127) //translucent
4427 {
4428 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4429 }
4430
4431
1/2
✓ Branch 0 taken 144 times.
✗ Branch 1 not taken.
144 if(sdci[10]!=0) //rotation
4432 {
4433 int32_t xy[4];
4434 int32_t rx=sdci[8]/10000;
4435 int32_t ry=sdci[9]/10000;
4436 fixed ra1=itofix(sdci[10]%10000)/10000;
4437 fixed ra2=itofix(sdci[10]/10000);
4438 fixed ra=ra1+ra2;
4439
4440 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4441 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4442 xy[ 2]=rx + fixtoi((fixcos(ra) * (x2 - rx) - fixsin(ra) * (y2 - ry))); //x2
4443 xy[ 3]=ry + fixtoi((fixsin(ra) * (x2 - rx) + fixcos(ra) * (y2 - ry))); //y2
4444 x1=xy[0];
4445 y1=xy[1];
4446 x2=xy[2];
4447 y2=xy[3];
4448 }
4449
4450 144 line(refbmp, x1+xoffset, y1+yoffset, x2+xoffset, y2+yoffset, color);
4451 144 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4452 144 }
4453
4454
4455 void bmp_do_spliner(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4456 {
4457 /* layer, x1, y1, x2, y2, x3, y3, x4, y4, color, opacity */
4458 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4459
4460 int32_t points[8] = { xoffset + (sdci[2]/10000), yoffset + (sdci[3]/10000),
4461 xoffset + (sdci[4]/10000), yoffset + (sdci[5]/10000),
4462 xoffset + (sdci[6]/10000), yoffset + (sdci[7]/10000),
4463 xoffset + (sdci[8]/10000), yoffset + (sdci[9]/10000)
4464 };
4465
4466 if(sdci[11]/10000 < 128) //translucent
4467 {
4468 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4469 }
4470
4471 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4472 {
4473 Z_scripterrlog("bitmap->Spline() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4474 return;
4475 }
4476
4477 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4478 if ( refbmp == NULL ) return;
4479
4480 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4481
4482 spline(refbmp, points, sdci[10]/10000);
4483
4484 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4485 }
4486
4487
4488 80910 void bmp_do_putpixelr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4489 {
4490 //sdci[1]=layer
4491 //sdci[2]=x
4492 //sdci[3]=y
4493 //sdci[4]=color
4494 //sdci[5]=rotation anchor x
4495 //sdci[6]=rotation anchor y
4496 //sdci[7]=rotation angle
4497 //sdci[8]=opacity
4498 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4499 80910 int32_t x1=sdci[2]/10000;
4500 80910 int32_t y1=sdci[3]/10000;
4501 80910 int32_t color=sdci[4]/10000;
4502
4503
1/2
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
80910 if(sdci[8]/10000<=127) //translucent
4504 {
4505 drawing_mode(DRAW_MODE_TRANS, NULL, 0, 0);
4506 }
4507
4508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80910 times.
80910 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4509 {
4510 Z_scripterrlog("bitmap->PutPixel() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4511 return;
4512 }
4513
4514 80910 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4515
1/2
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
80910 if ( refbmp == NULL ) return;
4516
4517
2/4
✓ Branch 0 taken 80910 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 80910 times.
✗ Branch 3 not taken.
80910 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4518
4519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80910 times.
80910 if(sdci[7]!=0) //rotation
4520 {
4521 int32_t xy[2];
4522 int32_t rx=sdci[5]/10000;
4523 int32_t ry=sdci[6]/10000;
4524 fixed ra1=itofix(sdci[7]%10000)/10000;
4525 fixed ra2=itofix(sdci[7]/10000);
4526 fixed ra=ra1+ra2;
4527
4528 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4529 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4530 x1=xy[0];
4531 y1=xy[1];
4532 }
4533
4534 80910 putpixel(refbmp, x1+xoffset, y1+yoffset, color);
4535 80910 drawing_mode(DRAW_MODE_SOLID, NULL, 0, 0);
4536 80910 }
4537
4538
4539 64994 void bmp_do_drawtiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4540 {
4541 //sdci[1]=layer
4542 //sdci[2]=x
4543 //sdci[3]=y
4544 //sdci[4]=tile
4545 //sdci[5]=tile width
4546 //sdci[6]=tile height
4547 //sdci[7]=color (cset)
4548 //sdci[8]=scale x
4549 //sdci[9]=scale y
4550 //sdci[10]=rotation anchor x
4551 //sdci[11]=rotation anchor y
4552 //sdci[12]=rotation angle
4553 //sdci[13]=flip
4554 //sdci[14]=transparency
4555 //sdci[15]=opacity
4556 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4557
4558 64994 int32_t w = sdci[5]/10000;
4559 64994 int32_t h = sdci[6]/10000;
4560
4561
4/8
✓ Branch 0 taken 64994 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 64994 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 64994 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 64994 times.
64994 if(w < 1 || h < 1 || h > 20 || w > 20)
4562 {
4563 return;
4564 }
4565
4566
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64994 times.
64994 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4567 {
4568 Z_scripterrlog("bitmap->DrawTile() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4569 return;
4570 }
4571
4572 64994 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4573
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64994 times.
64994 if ( refbmp == NULL ) return;
4574
4575 64994 int32_t xscale=sdci[8]/10000;
4576 64994 int32_t yscale=sdci[9]/10000;
4577 64994 int32_t rx = sdci[10]/10000;
4578 64994 int32_t ry = sdci[11]/10000;
4579 64994 float rotation=sdci[12]/10000;
4580 64994 int32_t flip=(sdci[13]/10000)&3;
4581 64994 bool transparency=sdci[14]!=0;
4582 64994 int32_t opacity=sdci[15]/10000;
4583 64994 int32_t color=sdci[7]/10000;
4584
4585 64994 int32_t x1=sdci[2]/10000;
4586 64994 int32_t y1=sdci[3]/10000;
4587
4588
4589 //don't scale if it's not safe to do so
4590 64994 bool canscale = true;
4591
4592
2/4
✓ Branch 0 taken 64994 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64994 times.
64994 if(xscale==0||yscale==0)
4593 {
4594 return;
4595 }
4596
4597
3/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 64088 times.
✓ Branch 2 taken 906 times.
✗ Branch 3 not taken.
64994 if(xscale<0||yscale<0)
4598 64088 canscale = false; //default size
4599
4600
2/4
✓ Branch 0 taken 64994 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 64994 times.
64994 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4601
4602
4/4
✓ Branch 0 taken 906 times.
✓ Branch 1 taken 64088 times.
✓ Branch 2 taken 5644 times.
✓ Branch 3 taken 58444 times.
64994 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
4603 {
4604 6550 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16);
4605
4606
1/2
✓ Branch 0 taken 6550 times.
✗ Branch 1 not taken.
6550 if(transparency) //transparency
4607 {
4608 6550 TileHelper::OverTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
4609 6550 }
4610 else //no transparency
4611 {
4612 TileHelper::OldPutTile(pbitty, (sdci[4]/10000), 0, 0, w, h, color, flip);
4613 }
4614
4615
2/2
✓ Branch 0 taken 5644 times.
✓ Branch 1 taken 906 times.
6550 if(rotation != 0)
4616 {
4617 //low negative values indicate no anchor-point rotation
4618
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 5644 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
5644 if(rx>-777||ry>-777)
4619 {
4620 int32_t xy[2];
4621 5644 fixed ra1=itofix(sdci[12]%10000)/10000;
4622 5644 fixed ra2=itofix(sdci[12]/10000);
4623 5644 fixed ra=ra1+ra2;
4624 5644 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4625 5644 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4626 5644 x1=xy[0];
4627 5644 y1=xy[1];
4628 5644 }
4629
4630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5644 times.
5644 if(canscale) //scale first
4631 {
4632 //damnit all, .. fixme.
4633 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
4634 clear_bitmap(tempbit);
4635
4636 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
4637
4638 if(opacity < 128)
4639 {
4640 clear_bitmap(prim_bmp);
4641 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
4642 draw_trans_sprite(bmp, prim_bmp, x1+xoffset, y1+yoffset);
4643 }
4644 else
4645 {
4646 rotate_sprite(refbmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4647 }
4648
4649 destroy_bitmap(tempbit);
4650 }
4651 else //no scale
4652 {
4653
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5644 times.
5644 if(opacity < 128)
4654 {
4655 clear_bitmap(prim_bmp);
4656 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
4657 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4658 }
4659 else
4660 {
4661 5644 rotate_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4662 }
4663 }
4664 5644 }
4665 else //scale only
4666 {
4667
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if(canscale)
4668 {
4669
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(opacity<128)
4670 {
4671 clear_bitmap(prim_bmp);
4672 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
4673 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4674 }
4675 else
4676 {
4677 906 stretch_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
4678 }
4679 906 }
4680 else //error -do not scale
4681 {
4682 if(opacity<128)
4683 {
4684 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4685 }
4686 else
4687 {
4688 draw_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset);
4689 }
4690 }
4691 }
4692
4693 6550 script_drawing_commands.ReleaseSubBitmap(pbitty);
4694
4695 6550 }
4696 else // no scale or rotation
4697 {
4698
2/2
✓ Branch 0 taken 50106 times.
✓ Branch 1 taken 8338 times.
58444 if(transparency)
4699 {
4700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50106 times.
50106 if(opacity<=127)
4701 TileHelper::OverTileTranslucent(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
4702 else
4703 50106 TileHelper::OverTile(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
4704 50106 }
4705 else
4706 {
4707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8338 times.
8338 if(opacity<=127)
4708 TileHelper::PutTileTranslucent(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip, opacity);
4709 else
4710 8338 TileHelper::OldPutTile(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, color, flip);
4711 }
4712 }
4713 64994 }
4714
4715 void bmp_do_drawtilecloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4716 {
4717 //sdci[1]=layer
4718 //sdci[2]=x
4719 //sdci[3]=y
4720 //sdci[4]=tile
4721 //sdci[5]=tile width
4722 //sdci[6]=tile height
4723 //sdci[7]=flip
4724 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4725
4726 int32_t w = sdci[5]/10000;
4727 int32_t h = sdci[6]/10000;
4728
4729 if(w < 1 || h < 1 || h > 20 || w > 20)
4730 {
4731 return;
4732 }
4733
4734 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4735 {
4736 Z_scripterrlog("bitmap->DrawTileCloaked() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4737 return;
4738 }
4739
4740 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4741 if ( refbmp == NULL ) return;
4742
4743 int32_t flip=(sdci[7]/10000)&3;
4744
4745 int32_t x1=sdci[2]/10000;
4746 int32_t y1=sdci[3]/10000;
4747
4748 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4749
4750 TileHelper::OverTileCloaked(refbmp, (sdci[4]/10000), xoffset+x1, yoffset+y1, w, h, flip);
4751 }
4752
4753
4754 11288 void bmp_do_drawcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4755 {
4756 //sdci[1]=layer
4757 //sdci[2]=x
4758 //sdci[3]=y
4759 //sdci[4]=combo
4760 //sdci[5]=tile width
4761 //sdci[6]=tile height
4762 //sdci[7]=color (cset)
4763 //sdci[8]=scale x
4764 //sdci[9]=scale y
4765 //sdci[10]=rotation anchor x
4766 //sdci[11]=rotation anchor y
4767 //sdci[12]=rotation angle
4768 //sdci[13]=frame
4769 //sdci[14]=flip
4770 //sdci[15]=transparency
4771 //sdci[16]=opacity
4772 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4773 11288 int32_t w = sdci[5]/10000;
4774 11288 int32_t h = sdci[6]/10000;
4775
4776
4/8
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11288 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 11288 times.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✓ Branch 7 taken 11288 times.
11288 if(w<1||h<1||h>20||w>20)
4777 {
4778 return;
4779 }
4780
4781
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
11288 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4782 {
4783 Z_scripterrlog("bitmap->DrawCombo() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4784 return;
4785 }
4786
4787 11288 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4788
1/2
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
11288 if ( refbmp == NULL ) return;
4789 11288 int32_t cmb = (sdci[4]/10000);
4790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
11288 if((unsigned)cmb >= MAXCOMBOS)
4791 {
4792 Z_scripterrlog("DrawCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
4793 return;
4794 }
4795
4796 11288 int32_t xscale=sdci[8]/10000;
4797 11288 int32_t yscale=sdci[9]/10000;
4798 11288 int32_t rx = sdci[10]/10000; //these work now
4799 11288 int32_t ry = sdci[11]/10000; //these work now
4800 11288 float rotation=sdci[12]/10000;
4801
4802 11288 bool transparency=sdci[15]!=0;
4803 11288 int32_t opacity=sdci[16]/10000;
4804 11288 int32_t color=sdci[7]/10000;
4805 11288 int32_t x1=sdci[2]/10000;
4806 11288 int32_t y1=sdci[3]/10000;
4807
4808 11288 auto& c = GET_DRAWING_COMBO(cmb);
4809
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
11288 if(c.animflags & AF_EDITOR_ONLY) return;
4810 11288 int32_t tiletodraw = combo_tile(c, x1, y1);
4811 11288 int32_t flip = ((sdci[14]/10000) & 3) ^ c.flip;
4812 11288 int32_t skiprows=c.skipanimy;
4813
4814
4815 //don't scale if it's not safe to do so
4816 11288 bool canscale = true;
4817
4818
2/4
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11288 times.
11288 if(xscale==0||yscale==0)
4819 {
4820 return;
4821 }
4822
4823
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
11288 if(xscale<0||yscale<0)
4824 11288 canscale = false; //default size
4825
4826
2/4
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 11288 times.
11288 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4827
4828
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 11288 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 11288 times.
11288 if((xscale>0 && yscale>0) || rotation) //scaled or rotated
4829 {
4830 BITMAP* pbitty = script_drawing_commands.AquireSubBitmap(w*16, h*16); //-pbitty in the hisouse. :D
4831
4832 if(transparency)
4833 {
4834 TileHelper::OverTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
4835 }
4836 else //no transparency
4837 {
4838 TileHelper::OldPutTile(pbitty, tiletodraw, 0, 0, w, h, color, flip, skiprows);
4839 }
4840
4841 if(rotation != 0) // rotate
4842 {
4843 //fixed point sucks ;0
4844 if(rx>-777||ry>-777) //set the rotation anchor and rotate around that
4845 {
4846 int32_t xy[2];
4847 fixed ra1=itofix(sdci[12]%10000)/10000;
4848 fixed ra2=itofix(sdci[12]/10000);
4849 fixed ra=ra1+ra2;
4850 xy[ 0]=rx + fixtoi((fixcos(ra) * (x1 - rx) - fixsin(ra) * (y1 - ry))); //x1
4851 xy[ 1]=ry + fixtoi((fixsin(ra) * (x1 - rx) + fixcos(ra) * (y1 - ry))); //y1
4852 x1=xy[0];
4853 y1=xy[1];
4854 }
4855
4856 if(canscale) //scale first
4857 {
4858 BITMAP* tempbit = create_bitmap_ex(8, xscale>512?512:xscale, yscale>512?512:yscale);
4859 clear_bitmap(tempbit);
4860
4861 stretch_sprite(tempbit, pbitty, 0, 0, xscale, yscale);
4862
4863 if(opacity < 128)
4864 {
4865 clear_bitmap(prim_bmp);
4866 rotate_sprite(prim_bmp, tempbit, 0, 0, degrees_to_fixed(rotation));
4867 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4868 }
4869 else
4870 {
4871 rotate_sprite(refbmp, tempbit, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4872 }
4873
4874 destroy_bitmap(tempbit);
4875 }
4876 else //no scale
4877 {
4878 if(opacity < 128)
4879 {
4880 clear_bitmap(prim_bmp);
4881 rotate_sprite(prim_bmp, pbitty, 0, 0, degrees_to_fixed(rotation));
4882 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4883 }
4884 else
4885 {
4886 rotate_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, degrees_to_fixed(rotation));
4887 }
4888 }
4889 }
4890 else //scale only
4891 {
4892 if(canscale)
4893 {
4894 if(opacity<128)
4895 {
4896 clear_bitmap(prim_bmp);
4897 stretch_sprite(prim_bmp, pbitty, 0, 0, xscale, yscale);
4898 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4899 }
4900 else
4901 {
4902 stretch_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset, xscale, yscale);
4903 }
4904 }
4905 else //error -do not scale
4906 {
4907 if(opacity<128)
4908 {
4909 draw_trans_sprite(refbmp, prim_bmp, x1+xoffset, y1+yoffset);
4910 }
4911 else
4912 {
4913 draw_sprite(refbmp, pbitty, x1+xoffset, y1+yoffset);
4914 }
4915 }
4916 }
4917
4918 script_drawing_commands.ReleaseSubBitmap(pbitty); //rap sucks
4919 }
4920 else // no scale or rotation
4921 {
4922
1/2
✓ Branch 0 taken 11288 times.
✗ Branch 1 not taken.
11288 if(transparency)
4923 {
4924
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 11006 times.
11288 if(opacity<=127)
4925 282 TileHelper::OverTileTranslucent(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4926 else
4927 11006 TileHelper::OverTile(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4928 11288 }
4929 else
4930 {
4931 if(opacity<=127)
4932 TileHelper::PutTileTranslucent(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, opacity, skiprows);
4933 else
4934 TileHelper::OldPutTile(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, color, flip, skiprows);
4935 }
4936 }
4937 11288 }
4938
4939
4940 void bmp_do_drawcombocloakedr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4941 {
4942 //sdci[1]=layer
4943 //sdci[2]=x
4944 //sdci[3]=y
4945 //sdci[4]=combo
4946 //sdci[5]=tile width
4947 //sdci[6]=tile height
4948 //sdci[7]=flip
4949 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4950
4951 int32_t w = sdci[5]/10000;
4952 int32_t h = sdci[6]/10000;
4953
4954 if(w<1||h<1||h>20||w>20)
4955 {
4956 return;
4957 }
4958
4959 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4960 {
4961 Z_scripterrlog("bitmap->DrawComboCloaked() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4962 return;
4963 }
4964
4965 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
4966 if ( refbmp == NULL ) return;
4967 int32_t cmb = (sdci[4]/10000);
4968 if((unsigned)cmb >= MAXCOMBOS)
4969 {
4970 Z_scripterrlog("DrawComboCloaked() cannot draw combo '%d', as it is out of bounds.\n", cmb);
4971 return;
4972 }
4973
4974 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
4975
4976 int32_t x1=sdci[2]/10000;
4977 int32_t y1=sdci[3]/10000;
4978
4979 auto& c = GET_DRAWING_COMBO(cmb);
4980 if(c.animflags & AF_EDITOR_ONLY) return;
4981 int32_t tiletodraw = combo_tile(c, x1, y1);
4982 int32_t flip = ((sdci[7]/10000) & 3) ^ c.flip;
4983 int32_t skiprows=c.skipanimy;
4984
4985 TileHelper::OverTileCloaked(refbmp, tiletodraw, xoffset+x1, yoffset+y1, w, h, flip, skiprows);
4986 }
4987
4988
4989 1982263 void bmp_do_fasttiler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
4990 {
4991 /* layer, x, y, tile, color opacity */
4992 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
4993
4994 1982263 int32_t opacity = sdci[6]/10000;
4995
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1982263 times.
1982263 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
4996 {
4997 Z_scripterrlog("bitmap->FastTile() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
4998 return;
4999 }
5000 1982263 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5001
1/2
✓ Branch 0 taken 1982263 times.
✗ Branch 1 not taken.
1982263 if ( refbmp == NULL ) return;
5002
5003
2/4
✓ Branch 0 taken 1982263 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1982263 times.
✗ Branch 3 not taken.
1982263 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5004
5005 1982263 int x = xoffset+(sdci[2]/10000);
5006 1982263 int y = yoffset+(sdci[3]/10000);
5007
5008
2/2
✓ Branch 0 taken 29119 times.
✓ Branch 1 taken 1953144 times.
1982263 if(opacity < 128)
5009 29119 overtiletranslucent16(refbmp, sdci[4]/10000, x, y, sdci[5]/10000, 0, opacity);
5010 else
5011 1953144 overtile16(refbmp, sdci[4]/10000, x, y, sdci[5]/10000, 0);
5012 1982263 }
5013
5014 19821648 void do_bmpwritetile(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5015 {
5016 /* layer, x, y, tile, is8bit, mask */
5017 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19821648 times.
19821648 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5019 {
5020 Z_scripterrlog("bitmap->WriteTile() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5021 return;
5022 }
5023 19821648 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5024
1/2
✓ Branch 0 taken 19821648 times.
✗ Branch 1 not taken.
19821648 if ( refbmp == NULL ) return;
5025
5026
2/4
✓ Branch 0 taken 19821648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 19821648 times.
✗ Branch 3 not taken.
19821648 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5027
5028 19821648 int32_t x = (sdci[2]/10000), y = (sdci[3]/10000), tl = (sdci[4]/10000);
5029 19821648 bool is8bit = sdci[5]!=0, mask = sdci[6]!=0;
5030
5031 19821648 write_tile(newtilebuf, refbmp, tl, x+xoffset, y+yoffset, is8bit, mask);
5032 19821648 }
5033
5034 void do_bmpdither(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5035 {
5036 /* layer, mask, color, ditherType, ditherArg */
5037 //sdci[2] Mask Bitmap Pointer
5038 //sdci[3] Color
5039 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5040 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5041 {
5042 Z_scripterrlog("bitmap->Dither() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5043 return;
5044 }
5045 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5046 if ( refbmp == NULL ) return;
5047 if ( sdci[2] <= 0 )
5048 {
5049 Z_scripterrlog("bitmap->Dither() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[2]);
5050 return;
5051 }
5052 BITMAP *mask = resolveScriptingBitmap(sdci[2]);
5053 if ( mask == NULL ) return;
5054
5055 int32_t dType = sdci[4] / 10000L;
5056 if(dType < 0 || dType >= dithMax)
5057 {
5058 Z_scripterrlog("bitmap->Dither() used an invalid dither type: %d. Aborting.\n", dType);
5059 return;
5060 }
5061
5062 ditherblit(refbmp, mask, byte(sdci[3]/10000L), dType, sdci[5]/10000L);
5063 }
5064
5065 7323 void do_bmpreplcol(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5066 {
5067 /* layer, shift, startcol, endcol */
5068 //sdci[2] NewCol
5069 //sdci[3] StartCol
5070 //sdci[4] EndCol
5071 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5072
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7323 times.
7323 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5073 {
5074 Z_scripterrlog("bitmap->ReplaceColors() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5075 return;
5076 }
5077 7323 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7323 times.
7323 if ( refbmp == NULL ) return;
5079 7323 replColor(refbmp, sdci[2]/10000L, sdci[3]/10000L, sdci[4]/10000L, false);
5080 7323 }
5081
5082 void do_bmpshiftcol(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5083 {
5084 /* layer, shift, startcol, endcol */
5085 //sdci[2] ShiftAmount
5086 //sdci[3] StartCol
5087 //sdci[4] EndCol
5088 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5089 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5090 {
5091 Z_scripterrlog("bitmap->ShiftColors() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5092 return;
5093 }
5094 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5095 if ( refbmp == NULL ) return;
5096 replColor(refbmp, sdci[2]/10000L, sdci[3]/10000L, sdci[4]/10000L, true);
5097 }
5098
5099 906 void do_bmpmaskdraw(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5100 {
5101 /* layer, mask, color */
5102 //sdci[2] Mask Bitmap Pointer
5103 //sdci[3] Color
5104 //sdci[4] start mask color
5105 //sdci[5] end mask color
5106 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5107 906 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5108
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( refbmp == NULL )
5109 {
5110 Z_scripterrlog("bitmap->MaskDraw() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5111 return;
5112 }
5113 906 BITMAP *mask = resolveScriptingBitmap(sdci[2]);
5114
1/2
✓ Branch 0 taken 906 times.
✗ Branch 1 not taken.
906 if ( mask == NULL )
5115 {
5116 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap id: %d. Aborting.\n", sdci[2]);
5117 return;
5118 }
5119 906 auto fillcol = sdci[3]/10000L;
5120
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 906 times.
906 if(unsigned(fillcol) > 0xFF) return; //invalid color, nothing to draw
5121 906 auto startcol = vbound(sdci[4]/10000L,0x00,0xFF);
5122 906 auto endcol = vbound(sdci[5]/10000L,0x00,0xFF);
5123 906 mask_colorfill(refbmp, mask, fillcol, startcol, endcol);
5124 906 }
5125
5126 void do_bmpmaskblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5127 {
5128 /* layer, mask, color */
5129 //sdci[2] Mask Bitmap Pointer
5130 //sdci[3] Pattern Bitmap
5131 //sdci[4] bool 'pattern repeats'
5132 //sdci[5] start mask color
5133 //sdci[6] end mask color
5134 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5135 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5136 if ( refbmp == NULL )
5137 {
5138 Z_scripterrlog("bitmap->MaskDraw() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5139 return;
5140 }
5141 BITMAP *mask = resolveScriptingBitmap(sdci[2]);
5142 if ( mask == NULL )
5143 {
5144 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap (mask) id: %d. Aborting.\n", sdci[2]);
5145 return;
5146 }
5147 BITMAP *pattern = resolveScriptingBitmap(sdci[3]);
5148 if ( pattern == NULL )
5149 {
5150 Z_scripterrlog("bitmap->MaskDraw() wanted to read from an invalid bitmap (pattern) id: %d. Aborting.\n", sdci[3]);
5151 return;
5152 }
5153 bool repeats = sdci[4]!=0;
5154 auto startcol = vbound(sdci[5]/10000L,0x00,0xFF);
5155 auto endcol = vbound(sdci[6]/10000L,0x00,0xFF);
5156 mask_blit(refbmp, mask, pattern, repeats, startcol, endcol);
5157 }
5158
5159 40175665 void bmp_do_fastcombor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5160 {
5161 /* layer, x, y, tile, color opacity */
5162 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5163 40175665 int32_t opacity = sdci[6] / 10000;
5164 40175665 int32_t x1 = sdci[2] / 10000;
5165 40175665 int32_t y1 = sdci[3] / 10000;
5166 40175665 int32_t index = sdci[4]/10000;
5167
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40175665 times.
40175665 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5168 {
5169 Z_scripterrlog("bitmap->FastCombo() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5170 return;
5171 }
5172 40175665 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5173
1/2
✓ Branch 0 taken 40175665 times.
✗ Branch 1 not taken.
40175665 if ( refbmp == NULL ) return;
5174 40175665 int32_t cmb = (sdci[4]/10000);
5175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40175665 times.
40175665 if((unsigned)cmb >= MAXCOMBOS)
5176 {
5177 Z_scripterrlog("FastCombo() cannot draw combo '%d', as it is out of bounds.\n", cmb);
5178 return;
5179 }
5180
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40175665 times.
40175665 if(combobuf[cmb].animflags & AF_EDITOR_ONLY) return;
5181
5182
2/4
✓ Branch 0 taken 40175665 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 40175665 times.
✗ Branch 3 not taken.
40175665 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5183
5184 40175665 int x = xoffset+x1;
5185 40175665 int y = yoffset+y1;
5186
5187
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40175665 times.
40175665 if(opacity < 128)
5188 {
5189 overcomboblocktranslucent(refbmp, x, y, cmb, sdci[5]/10000, 1, 1, 128);
5190
5191 }
5192 else
5193 {
5194 40175665 overcomboblock(refbmp, x, y, cmb, sdci[5]/10000, 1, 1);
5195 }
5196 40175665 }
5197
5198
5199
5200 void bmp_do_drawcharr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5201 {
5202 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5203 {
5204 Z_scripterrlog("bitmap->DrawCharacter() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5205 return;
5206 }
5207 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5208 if ( refbmp == NULL ) return;
5209
5210 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5211
5212 //broken 2.50.2 and earlier drawcharacter()
5213 if ( get_qr(qr_BROKENCHARINTDRAWING) )
5214 {
5215 //sdci[1]=layer
5216 //sdci[2]=x
5217 //sdci[3]=y
5218 //sdci[4]=font
5219 //sdci[5]=color
5220 //sdci[6]=bg color
5221 //sdci[7]=strech x (width)
5222 //sdci[8]=stretch y (height)
5223 //sdci[9]=char
5224 //sdci[10]=opacity
5225 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5226
5227 int32_t x=sdci[2]/10000;
5228 int32_t y=sdci[3]/10000;
5229 int32_t font_index=sdci[4]/10000;
5230 int32_t color=sdci[5]/10000;
5231 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5232 int32_t w=sdci[7]/10000;
5233 int32_t h=sdci[8]/10000;
5234 char glyph=char(sdci[9]/10000);
5235 int32_t opacity=sdci[10]/10000;
5236
5237 //safe check
5238 if(bg_color < -1) bg_color = -1;
5239
5240 if(w>512) w=512; //w=vbound(w,0,512);
5241
5242 if(h>512) h=512; //h=vbound(h,0,512);
5243
5244 //undone
5245 if(w>0&&h>0)//stretch the character
5246 {
5247 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5248
5249 if(opacity < 128)
5250 {
5251 if(w>128||h>128)
5252 {
5253 clear_bitmap(prim_bmp);
5254
5255 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5256 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5257 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5258 }
5259 else //this is faster
5260 {
5261 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
5262
5263 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5264 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5265 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5266
5267 script_drawing_commands.ReleaseSubBitmap(pbmp2);
5268 }
5269 }
5270 else // no opacity
5271 {
5272 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5273 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5274 }
5275
5276 }
5277 else //no stretch
5278 {
5279 if(opacity < 128)
5280 {
5281 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5282 clear_bitmap(pbmp);
5283
5284 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5285 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5286
5287 destroy_bitmap(pbmp);
5288 }
5289 else // no opacity
5290 {
5291 textprintf_ex(refbmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
5292 }
5293 }
5294 }
5295
5296 else //2.53.0 fixed version and later.
5297 {
5298
5299 //sdci[1]=layer
5300 //sdci[2]=x
5301 //sdci[3]=y
5302 //sdci[4]=font
5303 //sdci[5]=color
5304 //sdci[6]=bg color
5305 //sdci[7]=strech x (width)
5306 //sdci[8]=stretch y (height)
5307 //sdci[9]=char
5308 //sdci[10]=opacity
5309
5310 int32_t x=sdci[2]/10000;
5311 int32_t y=sdci[3]/10000;
5312 int32_t font_index=sdci[4]/10000;
5313 int32_t color=sdci[5]/10000;
5314 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5315 int32_t w=sdci[7]/10000;
5316 int32_t h=sdci[8]/10000;
5317 char glyph=char(sdci[9]/10000);
5318 int32_t opacity=sdci[10]/10000;
5319
5320 //safe check
5321 if(bg_color < -1) bg_color = -1;
5322
5323 if(w>512) w=512; //w=vbound(w,0,512);
5324
5325 if(h>512) h=512; //h=vbound(h,0,512);
5326
5327 //undone
5328 if(w>0&&h>0)//stretch the character
5329 {
5330 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5331
5332 if(opacity < 128)
5333 {
5334 if(w>128||h>128)
5335 {
5336 clear_bitmap(prim_bmp);
5337
5338 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5339 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5340 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5341 }
5342 else //this is faster
5343 {
5344 BITMAP *pbmp2 = script_drawing_commands.AquireSubBitmap(w,h);
5345
5346 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5347 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5348 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5349
5350 script_drawing_commands.ReleaseSubBitmap(pbmp2);
5351 }
5352 }
5353 else // no opacity
5354 {
5355 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5356 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5357 }
5358
5359 }
5360 else //no stretch
5361 {
5362 if(opacity < 128)
5363 {
5364 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5365 clear_bitmap(pbmp);
5366
5367 textprintf_ex(pbmp, get_zc_font(font_index), 0, 0, color, bg_color, "%c", glyph);
5368 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5369
5370 destroy_bitmap(pbmp);
5371 }
5372 else // no opacity
5373 {
5374 textprintf_ex(refbmp, get_zc_font(font_index), x+xoffset, y+yoffset, color, bg_color, "%c", glyph);
5375 }
5376 }
5377
5378 }
5379
5380 }
5381
5382
5383 void bmp_do_drawintr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5384 {
5385 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5386 {
5387 Z_scripterrlog("bitmap->DrawInteger() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5388 return;
5389 }
5390 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5391 if ( refbmp == NULL ) return;
5392
5393 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5394
5395 //broken 2.50.2 and earlier drawinteger()
5396 if ( get_qr(qr_BROKENCHARINTDRAWING) )
5397 {
5398 //sdci[1]=layer
5399 //sdci[2]=x
5400 //sdci[3]=y
5401 //sdci[4]=font
5402 //sdci[5]=color
5403 //sdci[6]=bg color
5404 //sdci[7]=strech x (width)
5405 //sdci[8]=stretch y (height)
5406 //sdci[9]=integer
5407 //sdci[10]=num decimal places
5408 //sdci[11]=opacity
5409 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5410
5411 int32_t x=sdci[2]/10000;
5412 int32_t y=sdci[3]/10000;
5413 int32_t font_index=sdci[4]/10000;
5414 int32_t color=sdci[5]/10000;
5415 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5416 int32_t w=sdci[7]/10000;
5417 int32_t h=sdci[8]/10000;
5418 int32_t decplace=sdci[10]/10000;
5419 int32_t opacity=sdci[11]/10000;
5420
5421 //safe check
5422 if(bg_color < -1) bg_color = -1;
5423
5424 if(w>512) w=512; //w=vbound(w,0,512);
5425
5426 if(h>512) h=512; //h=vbound(h,0,512);
5427
5428 char numbuf[15];
5429
5430 switch(decplace)
5431 {
5432 default:
5433 case 0:
5434 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
5435 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
5436
5437 case 1:
5438 //sprintf(numbuf,"%.01f",number);
5439 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
5440 break;
5441
5442 case 2:
5443 //sprintf(numbuf,"%.02f",number);
5444 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
5445 break;
5446
5447 case 3:
5448 //sprintf(numbuf,"%.03f",number);
5449 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
5450 break;
5451
5452 case 4:
5453 //sprintf(numbuf,"%.04f",number);
5454 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
5455 break;
5456 }
5457
5458 if(w>0&&h>0)//stretch
5459 {
5460 BITMAP *pbmp = script_drawing_commands.GetSmallTextureBitmap(1,1);
5461
5462 if(opacity < 128)
5463 {
5464 if(w>128||h>128)
5465 {
5466 clear_bitmap(prim_bmp);
5467
5468 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5469 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5470 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5471 }
5472 else
5473 {
5474 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
5475 clear_bitmap(pbmp2);
5476
5477 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5478 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5479 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5480
5481 destroy_bitmap(pbmp2);
5482 }
5483 }
5484 else // no opacity
5485 {
5486 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5487 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5488 }
5489
5490 }
5491 else //no stretch
5492 {
5493 if(opacity < 128)
5494 {
5495 BITMAP *pbmp = create_sub_bitmap(prim_bmp,0,0,16,16);
5496 clear_bitmap(pbmp);
5497
5498 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5499 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5500
5501 destroy_bitmap(pbmp);
5502 }
5503 else // no opacity
5504 {
5505 textout_ex(refbmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
5506 }
5507 }
5508
5509 }
5510
5511 else //2.53.0 fixed version and later.
5512 {
5513 //sdci[1]=layer
5514 //sdci[2]=x
5515 //sdci[3]=y
5516 //sdci[4]=font
5517 //sdci[5]=color
5518 //sdci[6]=bg color
5519 //sdci[7]=strech x (width)
5520 //sdci[8]=stretch y (height)
5521 //sdci[9]=integer
5522 //sdci[10]=num decimal places
5523 //sdci[11]=opacity
5524
5525 int32_t x=sdci[2]/10000;
5526 int32_t y=sdci[3]/10000;
5527 int32_t font_index=sdci[4]/10000;
5528 int32_t color=sdci[5]/10000;
5529 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5530 int32_t w=sdci[7]/10000;
5531 int32_t h=sdci[8]/10000;
5532 int32_t decplace=sdci[10]/10000;
5533 int32_t opacity=sdci[11]/10000;
5534
5535 //safe check
5536 if(bg_color < -1) bg_color = -1;
5537
5538 if(w>512) w=512; //w=vbound(w,0,512);
5539
5540 if(h>512) h=512; //h=vbound(h,0,512);
5541
5542 char numbuf[15];
5543
5544 switch(decplace)
5545 {
5546 default:
5547 case 0:
5548 sprintf(numbuf,"%d",(sdci[9]/10000)); //For some reason, static casting for zero decimal places was
5549 break; //reducing the value by -1, so 8.000 printed as '7'. -Z
5550
5551 case 1:
5552 //sprintf(numbuf,"%.01f",number);
5553 sprintf(numbuf,"%.01f",(static_cast<float>(sdci[9])/10000.0f)); //Would this be slower?
5554 break;
5555
5556 case 2:
5557 //sprintf(numbuf,"%.02f",number);
5558 sprintf(numbuf,"%.02f",(static_cast<float>(sdci[9])/10000.0f));
5559 break;
5560
5561 case 3:
5562 //sprintf(numbuf,"%.03f",number);
5563 sprintf(numbuf,"%.03f",(static_cast<float>(sdci[9])/10000.0f));
5564 break;
5565
5566 case 4:
5567 //sprintf(numbuf,"%.04f",number);
5568 sprintf(numbuf,"%.04f",(static_cast<float>(sdci[9])/10000.0f));
5569 break;
5570 }
5571
5572 //FONT* font=get_zc_font(sdci[4]/10000);
5573
5574 if(w>0&&h>0)//stretch
5575 {
5576 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(get_zc_font(font_index), numbuf)+1, text_height(get_zc_font(font_index)));
5577 clear_bitmap(pbmp);
5578 //script_drawing_commands.GetSmallTextureBitmap(1,1);
5579
5580 if(opacity < 128)
5581 {
5582 if(w>128||h>128)
5583 {
5584 clear_bitmap(prim_bmp);
5585
5586 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5587 stretch_sprite(prim_bmp, pbmp, 0, 0, w, h);
5588 draw_trans_sprite(refbmp, prim_bmp, x+xoffset, y+yoffset);
5589 }
5590 else
5591 {
5592 BITMAP *pbmp2 = create_sub_bitmap(prim_bmp,0,0,w,h);
5593 clear_bitmap(pbmp2);
5594
5595 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5596 stretch_sprite(pbmp2, pbmp, 0, 0, w, h);
5597 draw_trans_sprite(refbmp, pbmp2, x+xoffset, y+yoffset);
5598
5599 destroy_bitmap(pbmp2);
5600 }
5601 }
5602 else // no opacity
5603 {
5604 textout_ex(pbmp, get_zc_font(font_index), numbuf, 0, 0, color, bg_color);
5605 stretch_sprite(refbmp, pbmp, x+xoffset, y+yoffset, w, h);
5606 }
5607
5608 }
5609 else //no stretch
5610 {
5611 if(opacity < 128)
5612 {
5613 FONT* font = get_zc_font(font_index);
5614 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, text_length(font, numbuf), text_height(font));
5615 clear_bitmap(pbmp);
5616
5617 textout_ex(pbmp, font, numbuf, 0, 0, color, bg_color);
5618 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5619
5620 destroy_bitmap(pbmp);
5621 }
5622 else // no opacity
5623 {
5624 textout_ex(refbmp, get_zc_font(font_index), numbuf, x+xoffset, y+yoffset, color, bg_color);
5625 }
5626 }
5627 }
5628 }
5629
5630
5631 865 void bmp_do_drawstringr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5632 {
5633 //sdci[1]=layer
5634 //sdci[2]=x
5635 //sdci[3]=y
5636 //sdci[4]=font
5637 //sdci[5]=color
5638 //sdci[6]=bg color
5639 //sdci[7]=format_option
5640 //sdci[8]=string
5641 //sdci[9]=opacity
5642 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5643
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5644 {
5645 Z_scripterrlog("bitmap->DrawString() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5646 return;
5647 }
5648
5649 865 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5650
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 if ( refbmp == NULL ) return;
5651
5652
2/4
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 865 times.
865 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5653
5654 865 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5655
5656
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 if(!str)
5657 {
5658 al_trace("String pointer is null! Internal error. \n");
5659 return;
5660 }
5661
5662 865 int32_t x=sdci[2]/10000;
5663 865 int32_t y=sdci[3]/10000;
5664 865 FONT* font=get_zc_font(sdci[4]/10000);
5665 865 int32_t color=sdci[5]/10000;
5666 865 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5667 865 int32_t format_type=sdci[7]/10000;
5668 865 int32_t opacity=sdci[9]/10000;
5669 //sdci[8] not needed :)
5670
5671 //safe check
5672
1/2
✓ Branch 0 taken 865 times.
✗ Branch 1 not taken.
865 if(bg_color < -1) bg_color = -1;
5673
5674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if(opacity < 128)
5675 {
5676 int32_t width=zc_min(text_length(font, str->c_str()), 512);
5677 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
5678 clear_bitmap(pbmp);
5679 textout_ex(pbmp, font, str->c_str(), 0, 0, color, bg_color);
5680 if(format_type == 2) // right-sided text
5681 x-=width;
5682 else if(format_type == 1) // centered text
5683 x-=width/2;
5684 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5685 destroy_bitmap(pbmp);
5686 }
5687 else // no opacity
5688 {
5689
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 if(format_type == 2) // right-sided text
5690 {
5691 textout_right_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5692 }
5693
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 865 times.
865 else if(format_type == 1) // centered text
5694 {
5695 textout_centre_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5696 }
5697 else // standard left-sided text
5698 {
5699 865 textout_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, color, bg_color);
5700 }
5701 }
5702 865 }
5703
5704 45504 void bmp_do_drawstringr2(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5705 {
5706 //sdci[1]=layer
5707 //sdci[2]=x
5708 //sdci[3]=y
5709 //sdci[4]=font
5710 //sdci[5]=color
5711 //sdci[6]=bg color
5712 //sdci[7]=format_option
5713 //sdci[8]=string
5714 //sdci[9]=opacity
5715 //sdci[10]=shadowtype
5716 //sdci[11]=shadow_color
5717 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5718
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45504 times.
45504 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5719 {
5720 Z_scripterrlog("bitmap->DrawString() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5721 return;
5722 }
5723
5724 45504 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5725
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if ( refbmp == NULL ) return;
5726
5727
2/4
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 45504 times.
45504 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
5728
5729 45504 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5730
5731
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if(!str)
5732 {
5733 al_trace("String pointer is null! Internal error. \n");
5734 return;
5735 }
5736
5737 45504 int32_t x=sdci[2]/10000;
5738 45504 int32_t y=sdci[3]/10000;
5739 45504 FONT* font=get_zc_font(sdci[4]/10000);
5740 45504 int32_t color=sdci[5]/10000;
5741 45504 int32_t bg_color=sdci[6]/10000; //-1 = transparent
5742 45504 int32_t format_type=sdci[7]/10000;
5743 45504 int32_t opacity=sdci[9]/10000;
5744 45504 int32_t textstyle = sdci[10]/10000;
5745 45504 int32_t shadow_color = sdci[11]/10000;
5746 //sdci[8] not needed :)
5747
5748 //safe check
5749
1/2
✓ Branch 0 taken 45504 times.
✗ Branch 1 not taken.
45504 if(bg_color < -1) bg_color = -1;
5750
5751
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45504 times.
45504 if(opacity < 128)
5752 {
5753 int32_t width=zc_min(text_length(font, str->c_str()), 512);
5754 BITMAP *pbmp = create_sub_bitmap(prim_bmp, 0, 0, width, text_height(font));
5755 clear_bitmap(pbmp);
5756 textout_styled_aligned_ex(pbmp, font, str->c_str(), 0, 0, textstyle, ALIGN_LEFT, color, shadow_color, bg_color);
5757 if(format_type == 2) // right-sided text
5758 x-=width;
5759 else if(format_type == 1) // centered text
5760 x-=width/2;
5761 draw_trans_sprite(refbmp, pbmp, x+xoffset, y+yoffset);
5762 destroy_bitmap(pbmp);
5763 }
5764 else // no opacity
5765 {
5766 45504 textout_styled_aligned_ex(refbmp, font, str->c_str(), x+xoffset, y+yoffset, textstyle, format_type, color, shadow_color, bg_color);
5767 }
5768 45504 }
5769
5770 2134433 void bmp_do_clearr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5771 {
5772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2134433 times.
2134433 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5773 {
5774 Z_scripterrlog("bitmap->Clear() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5775 return;
5776 }
5777
5778 2134433 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5779
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2134433 times.
2134433 if ( !refbmp ) return;
5780
5781 2134433 clear_bitmap(refbmp);
5782 2134433 }
5783
5784 34749 void bmp_do_clearcolorr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5785 {
5786 //sdci[1]=layer
5787 //sdci[2]=color
5788 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5789 34749 int32_t pal_color = sdci[2]/10000;
5790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34749 times.
34749 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5791 {
5792 Z_scripterrlog("bitmap->ClearToColor() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5793 return;
5794 }
5795
5796 34749 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34749 times.
34749 if ( !refbmp ) return;
5798
5799 34749 clear_to_color(refbmp, pal_color);
5800 34749 }
5801
5802
5803 43007 void bmp_do_regenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5804 {
5805 //sdci[1]=layer
5806 43007 int32_t h = sdci[3]/10000;
5807 43007 int32_t w = sdci[2]/10000;
5808
1/2
✓ Branch 0 taken 43007 times.
✗ Branch 1 not taken.
43007 if ( get_qr(qr_OLDCREATEBITMAP_ARGS) )
5809 {
5810 //flip height and width
5811 h = h ^ w;
5812 w = h ^ w;
5813 h = h ^ w;
5814 }
5815 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5816 //Z_scripterrlog("bitmap->Create() pointer is: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43007 times.
43007 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5818 {
5819 Z_scripterrlog("bitmap->Create() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5820 return;
5821 }
5822 43007 int32_t bitid = sdci[DRAWCMD_BMP_TARGET];
5823 43007 auto& usr_bmp = scb.get(bitid);
5824
2/2
✓ Branch 0 taken 42757 times.
✓ Branch 1 taken 250 times.
43007 if ( usr_bmp.u_bmp )
5825 42757 destroy_bitmap(usr_bmp.u_bmp);
5826 43007 usr_bmp.u_bmp = create_bitmap_ex(8,w,h);
5827
5828 43007 usr_bmp.width = w;
5829 43007 usr_bmp.height = h;
5830 43007 }
5831
5832 void bmp_do_readr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5833 {
5834 //sdci[1]=layer
5835 //sdci[2]=filename
5836 //sdci[3]=y
5837 //sdci[4]=font
5838 //sdci[5]=color
5839 //sdci[6]=bg color
5840 //sdci[7]=format_option
5841 //sdci[8]=string
5842 //sdci[9]=opacity
5843 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5844 //Z_scripterrlog("bitmap->Read() pointer is: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5845 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5846 {
5847 Z_scripterrlog("bitmap->Read() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5848 return;
5849 }
5850 int32_t bitid = sdci[DRAWCMD_BMP_TARGET];
5851 auto& usr_bitmap = scb.get(bitid);
5852 usr_bitmap.destroy();
5853
5854 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5855
5856 if(!str)
5857 {
5858 al_trace("String pointer is null! Internal error. \n");
5859 return;
5860 }
5861
5862 PALETTE tempPal;
5863 get_palette(tempPal);
5864 if ( checkPath(str->c_str(), false) )
5865 {
5866 usr_bitmap.u_bmp = load_bitmap(str->c_str(), tempPal);
5867 usr_bitmap.width = usr_bitmap.u_bmp->w;
5868 usr_bitmap.height = usr_bitmap.u_bmp->h;
5869 if ( !usr_bitmap.u_bmp )
5870 {
5871 Z_scripterrlog("Failed to load image file %s.\nMaking a blank bitmap on the pointer.\n", str->c_str());
5872 }
5873 else
5874 {
5875 zprint("Read image file %s\n",str->c_str());
5876 }
5877 }
5878 else
5879 {
5880 Z_scripterrlog("Failed to load image file: %s. File not found. Creating a blank bitmap on the pointer.\n", str->c_str());
5881 usr_bitmap.u_bmp = create_bitmap_ex(8,256,176);
5882 clear_bitmap(usr_bitmap.u_bmp);
5883 }
5884 }
5885
5886
5887
5888 void bmp_do_writer(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5889 {
5890 //sdci[1]=layer
5891 //sdci[2]=filename
5892 //sdci[3]=y
5893 //sdci[4]=font
5894 //sdci[5]=color
5895 //sdci[6]=bg color
5896 //sdci[7]=format_option
5897 //sdci[8]=string
5898 //sdci[9]=opacity
5899 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5900 //Z_scripterrlog("bitmap->Write() pointer is: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5901
5902 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5903 {
5904 Z_scripterrlog("bitmap->Write() wanted to use to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5905 return;
5906 }
5907
5908 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5909 if ( !refbmp ) return;
5910
5911 bool overwrite = (sdci[3] != 0);
5912 std::string* str = (std::string*)script_drawing_commands[i].GetPtr();
5913
5914 if(!str)
5915 {
5916 al_trace("String pointer is null! Internal error. \n");
5917 return;
5918 }
5919
5920 //char *cptr = new char[str->size()+1]; // +1 to account for \0 byte
5921 //std::strncpy(cptr, str->c_str(), str->size());
5922 //Z_scripterrlog("bitmap->Write extension matches ? : %s\n!", (FFCore.checkExtension(str->c_str(), ".png")) ? "true" : "false");
5923 //Z_scripterrlog("Trying to write filename %s\n", cptr);
5924 if
5925 (
5926 ( (FFCore.checkExtension(*str, "")) ) ||
5927 ( !(FFCore.checkExtension(*str, ".png")) && !(FFCore.checkExtension(*str, ".gif")) && !(FFCore.checkExtension(*str, ".bmp"))
5928 && !(FFCore.checkExtension(*str, ".pcx")) && !(FFCore.checkExtension(*str, ".tga")) )
5929 )
5930 {
5931 Z_scripterrlog("No extension, or invalid extension provided for writing bitmap file %s. Could not write the file.\nValid types are .png, .gif, .pcx, .tgx, and .bmp. Aborting.\n",str->c_str());
5932 }
5933 else if ( overwrite || (!checkPath(str->c_str(), false)) )
5934 {
5935 if(make_dirs_for_file(*str))
5936 {
5937 save_bitmap(str->c_str(), refbmp, RAMpal);
5938 if(checkPath(str->c_str(), false))
5939 {
5940 zprint("Wrote image file %s\n",str->c_str());
5941 }
5942 else
5943 {
5944 Z_scripterrlog("Failed to create file '%s'\n",str->c_str());
5945 }
5946 }
5947 else
5948 {
5949 Z_scripterrlog("Cannot write file '%s' because the directory does not exist, and could not be created.\n", str->c_str());
5950 }
5951 }
5952 else Z_scripterrlog("Cannot write file '%s' because the file already exists in the specified path.\n", str->c_str());
5953 }
5954
5955
5956 void bmp_do_drawquadr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
5957 {
5958 //sdci[1]=layer
5959 //sdci[2]=x1
5960 //sdci[3]=y1
5961 //sdci[4]=x2
5962 //sdci[5]=y2
5963 //sdci[6]=x3
5964 //sdci[7]=y3
5965 //sdci[8]=x4
5966 //sdci[9]=y4
5967 //sdci[10]=width
5968 //sdci[11]=height
5969 //sdci[12]=cset
5970 //sdci[13]=flip
5971 //sdci[14]=tile/combo
5972 //sdci[15]=polytype
5973 //sdci[16] = other bitmap as texture
5974 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
5975 Z_scripterrlog("bitmap quad pointer: %d\n", sdci[DRAWCMD_BMP_TARGET]);
5976 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
5977 {
5978 Z_scripterrlog("bitmap->Quad() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
5979 return;
5980 }
5981 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
5982
5983 if ( !refbmp ) return;
5984
5985 int32_t x1 = sdci[2]/10000;
5986 int32_t y1 = sdci[3]/10000;
5987 int32_t x2 = sdci[4]/10000;
5988 int32_t y2 = sdci[5]/10000;
5989 int32_t x3 = sdci[6]/10000;
5990 int32_t y3 = sdci[7]/10000;
5991 int32_t x4 = sdci[8]/10000;
5992 int32_t y4 = sdci[9]/10000;
5993 int32_t w = sdci[10]/10000;
5994 int32_t h = sdci[11]/10000;
5995 int32_t color = sdci[12]/10000;
5996 int32_t flip=(sdci[13]/10000)&3;
5997 int32_t tile = sdci[14]/10000;
5998 int32_t polytype = sdci[15]/10000;
5999 int32_t quad_render_source = sdci[16];
6000 //Z_scripterrlog("bitmap->Quad() render source is: %d\n", quad_render_source);
6001
6002 bool tex_is_bitmap = ( sdci[16] != 0 );
6003
6004 BITMAP *bmptexture=NULL;
6005 BITMAP *tex=NULL;
6006 polytype = vbound(polytype, 0, 14);
6007
6008 int32_t col[4];
6009 col[0]=col[1]=col[2]=col[3]=color;
6010 bool mustDestroyBmp = false;
6011
6012 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
6013
6014 if ( tex_is_bitmap )
6015 {
6016 bmptexture = resolveScriptingBitmap(quad_render_source);
6017 if ( !bmptexture )
6018 {
6019 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
6020 tex_is_bitmap = 0;
6021 }
6022 }
6023
6024 if ( tex_is_bitmap )
6025 {
6026
6027 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
6028 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
6029 if ( !isPowerOfTwo(w) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", w);
6030 if ( !isPowerOfTwo(h) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Quad is not a POWER OF TWO.\nTextels may render improperly!\n", h);
6031
6032 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6033 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), col[1] };
6034 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h), col[2] };
6035 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, col[3] };
6036
6037 quad3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3, &V4);
6038 }
6039 else
6040 {
6041 tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
6042 if(!tex)
6043 {
6044 //Z_scripterrlog("Bitmap->Quad() found an invalid texture bitmap.\n");
6045 mustDestroyBmp = true;
6046 tex = create_bitmap_ex(8, w*16, h*16);
6047 clear_bitmap(tex);
6048 }
6049
6050 if(tile > 0) // TILE
6051 {
6052 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
6053 }
6054
6055 if ( tile < 0 ) // COMBO
6056 {
6057 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
6058 const int32_t tiletodraw = combo_tile(c, x1, y1);
6059 flip = flip ^ c.flip;
6060
6061 if(!(c.animflags & AF_EDITOR_ONLY))
6062 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
6063 }
6064 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
6065 {
6066 Z_message("Quad() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
6067 return; //non power of two error
6068 }
6069 //Z_scripterrlog("bitmap->Quad() is trying to blit from a bitmap texture.\n");
6070 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6071 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(h), col[1] };
6072 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(w), static_cast<float>(h), col[2] };
6073 V3D_f V4 = { static_cast<float>(x4+xoffset), static_cast<float>(y4+yoffset), 0, static_cast<float>(w), 0, col[3] };
6074
6075 quad3d_f(refbmp, polytype, tex, &V1, &V2, &V3, &V4);
6076
6077 }
6078
6079
6080
6081
6082 //todo: finish palette shading
6083 /*
6084 POLYTYPE_FLAT
6085 POLYTYPE_GCOL
6086 POLYTYPE_GRGB
6087 POLYTYPE_ATEX
6088 POLYTYPE_PTEX
6089 POLYTYPE_ATEX_MASK
6090 POLYTYPE_PTEX_MASK
6091 POLYTYPE_ATEX_LIT
6092 POLYTYPE_PTEX_LIT
6093 POLYTYPE_ATEX_MASK_LIT
6094 POLYTYPE_PTEX_MASK_LIT
6095 POLYTYPE_ATEX_TRANS
6096 POLYTYPE_PTEX_TRANS
6097 POLYTYPE_ATEX_MASK_TRANS
6098 POLYTYPE_PTEX_MASK_TRANS
6099 */
6100
6101 if(mustDestroyBmp)
6102 destroy_bitmap(tex);
6103
6104 }
6105
6106 void bmp_do_drawtriangler(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6107 {
6108 //sdci[1]=layer
6109 //sdci[2]=x1
6110 //sdci[3]=y1
6111 //sdci[4]=x2
6112 //sdci[5]=y2
6113 //sdci[6]=x3
6114 //sdci[7]=y3
6115 //sdci[8]=width
6116 //sdci[9]=height
6117 //sdci[10]=cset
6118 //sdci[11]=flip
6119 //sdci[12]=tile/combo
6120 //sdci[13]=polytype
6121 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
6122 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
6123 {
6124 Z_scripterrlog("bitmap->Triangle() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
6125 return;
6126 }
6127 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
6128 if ( refbmp == NULL ) return;
6129
6130
6131 int32_t render_source = sdci[14];
6132 //Z_scripterrlog("bitmap->Triangle() render source is: %d\n", render_source);
6133
6134 bool tex_is_bitmap = ( sdci[14] != 0 );
6135
6136 BITMAP *bmptexture=NULL;
6137 if ( tex_is_bitmap )
6138 {
6139 bmptexture = resolveScriptingBitmap(render_source);
6140 if ( !bmptexture )
6141 {
6142 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
6143 tex_is_bitmap = 0;
6144 }
6145 }
6146
6147 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
6148
6149 int32_t x1 = sdci[2]/10000;
6150 int32_t y1 = sdci[3]/10000;
6151 int32_t x2 = sdci[4]/10000;
6152 int32_t y2 = sdci[5]/10000;
6153 int32_t x3 = sdci[6]/10000;
6154 int32_t y3 = sdci[7]/10000;
6155 int32_t w = sdci[8]/10000;
6156 int32_t h = sdci[9]/10000;
6157 int32_t color = sdci[10]/10000;
6158 int32_t flip=(sdci[11]/10000)&3;
6159 int32_t tile = sdci[12]/10000;
6160 int32_t polytype = sdci[13]/10000;
6161
6162 polytype = vbound(polytype, 0, 14);
6163 int32_t utex_w = w;
6164 int32_t utex_h = h;
6165
6166
6167 int32_t tex_width = w*16;
6168 int32_t tex_height = h*16;
6169
6170 bool mustDestroyBmp = false;
6171 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
6172
6173 if(!tex)
6174 {
6175 mustDestroyBmp = true;
6176 tex = create_bitmap_ex(8, tex_width, tex_height);
6177 clear_bitmap(tex);
6178 }
6179
6180 int32_t col[3];
6181 /*
6182 if( color < 0 )
6183 {
6184 col[0]=draw_container.color_buffer[0];
6185 col[1]=draw_container.color_buffer[1];
6186 col[2]=draw_container.color_buffer[2];
6187 }
6188 else */
6189 {
6190 col[0]=col[1]=col[2]=color;
6191 }
6192
6193 if(tile > 0) // TILE
6194 {
6195 TileHelper::OverTile(tex, tile, 0, 0, w, h, color, flip);
6196 }
6197 else // COMBO
6198 {
6199 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
6200 const int32_t tiletodraw = combo_tile(c, x1, y1);
6201 flip = flip ^ c.flip;
6202
6203 if(!(c.animflags & AF_EDITOR_ONLY))
6204 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, color, flip);
6205 }
6206 if ( !tex_is_bitmap )
6207 {
6208 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
6209 {
6210 Z_message("bitmap->Triangle() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
6211 return; //non power of two error
6212 }
6213 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6214 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(tex_height), col[1] };
6215 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(tex_width), static_cast<float>(tex_height), col[2] };
6216
6217
6218 triangle3d_f(refbmp, polytype, tex, &V1, &V2, &V3);
6219
6220 }
6221
6222 else
6223 {
6224 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", render_source);
6225 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", render_source);
6226 if ( !isPowerOfTwo(utex_h) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", utex_w);
6227 if ( !isPowerOfTwo(utex_w) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Triangle is not a POWER OF TWO.\nTextels may render improperly!\n", utex_h);
6228
6229 V3D_f V1 = { static_cast<float>(x1+xoffset), static_cast<float>(y1+yoffset), 0, 0, 0, col[0] };
6230 V3D_f V2 = { static_cast<float>(x2+xoffset), static_cast<float>(y2+yoffset), 0, 0, static_cast<float>(utex_h), col[1] };
6231 V3D_f V3 = { static_cast<float>(x3+xoffset), static_cast<float>(y3+yoffset), 0, static_cast<float>(utex_w), static_cast<float>(utex_h), col[2] };
6232
6233
6234 triangle3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3);
6235
6236 }
6237
6238 if(mustDestroyBmp)
6239 destroy_bitmap(tex);
6240 }
6241
6242
6243 void bmp_do_mode7r(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6244 {
6245 /*
6246 int32_t layer, int32_t rt, int32_t srcX, int32_t srcY, int32_t srcW, int32_t srcH, int32_t destW, int32_t destH, int32_t angle, int32_t cx, int32_t cy, int32_t space_z, int32_t horizon,
6247 int32_t scale_x, int32_t scale_y){
6248
6249 //sdci[1]=layer
6250 //sdci[2]=bitmap target
6251 //
6252 // -2 is the current Render Target
6253 // -1, this is the screen (framebuf).
6254 // 0: Render target 0
6255 // 1: Render target 1
6256 // 2: Render target 2
6257 // 3: Render target 3
6258 // 4: Render target 4
6259 // 5: Render target 5
6260 // 6: Render target 6
6261 // Otherwise: The pointer to a bitmap.
6262
6263 //sdci[3]=sourcex
6264 //sdci[4]=sourcey
6265 //sdci[5]=sourcew
6266 //sdci[6]=sourceh
6267
6268 //sdci[7]=destw
6269 //sdci[8]=desth
6270 //sdci[9]=angle
6271 //scdi[10] = pivot cx
6272 //sdci[11] = pivot cy
6273 //sdci[12] = space Z
6274 //sdci[13] = horizon
6275 //scdi[14] = scale X
6276 //scdi[15] = scale Y
6277 //sdci[16] = masked?
6278 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
6279
6280
6281
6282 // ZScript-side constant values:
6283 const int32_t BITDX_NORMAL = 0;
6284 const int32_t BITDX_TRANS = 1; //Translucent
6285 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
6286 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
6287 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
6288 //Note: Some modes cannot be combined. if a combination is not supported, an error
6289 // detailing this will be shown in allegro.log.
6290
6291 //scdi[15] = litcolour
6292 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6293 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
6294
6295 //sdci[16]=mask
6296
6297 */
6298
6299
6300 int32_t bitmapIndex = sdci[2];
6301 int32_t usr_bitmap_index = sdci[2];
6302 //Z_scripterrlog("bitmap index is: %d\n",bitmapIndex);
6303 //Z_scripterrlog("DrawPlane() bitmapIndex is: %d\n", bitmapIndex);
6304
6305 if ( bitmapIndex >= 10000 )
6306 {
6307 bitmapIndex = bitmapIndex / 10000; //reduce if ZScript sent a raw value, such as bitmap = <int32_t> 8;
6308 }
6309 else if ( usr_bitmap_index > 0 )
6310 {
6311 bitmapIndex = usr_bitmap_index;
6312 // Z_scripterrlog("Mode7 is using a user bitmap target, pointer: %d\n", usr_bitmap_index);
6313 yoffset = 0;
6314 }
6315
6316 //rendering mode 7 args
6317 double srcX = sdci[3]/10000.0;
6318 double srcY = sdci[4]/10000.0;
6319 double destX = sdci[5]/10000.0;
6320 double destY = sdci[6]/10000.0;
6321
6322 double destW = sdci[7]/10000.0;
6323 double destH = sdci[8]/10000.0;
6324 double space_z = sdci[9]/10000.0;
6325 double horizon = sdci[10]/10000.0;
6326 double scale_x = sdci[11]/10000.0;
6327 double scale_y = sdci[12]/10000.0;
6328 byte masked = ( sdci[13] ) ? 1 : 0;
6329
6330
6331 int32_t ref = 0;
6332
6333 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
6334 //Do we need to also check the render target and do the same thing if the
6335 //dest == -2 and the render target is not RT_SCREEN?
6336
6337 ref = sdci[DRAWCMD_BMP_TARGET];
6338
6339
6340 if ( ref <= 0 )
6341 {
6342 Z_scripterrlog("bitmap->DrawPlane() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
6343 return;
6344 }
6345 BITMAP *sourceBitmap = resolveScriptingBitmap(ref); //This can be the screen, as -1.
6346
6347 if(!sourceBitmap)
6348 {
6349 Z_message("Warning: %d->DrawPlane() source bitmap contains invalid data or is not initialized.\n", ref);
6350 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6351 return;
6352 }
6353
6354 BITMAP *destBMP=NULL;
6355 switch(bitmapIndex)
6356 {
6357 // Current render target (RT_CURRENT).
6358 // This is the only reason we aren't using resolveScriptingBitmap for the target bitmap. All the other cases should be equivalent.
6359 case -2:
6360 {
6361 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
6362 if ( curr_rt >= 0 && curr_rt < 7 )
6363 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
6364 else destBMP = bmp; //screen
6365 break;
6366 }
6367 case -1:
6368 destBMP = bmp; //this is framebuf, by default
6369 break;
6370
6371 //1 through 6 are the old system bitmaps (Render Targets)
6372 case 0:
6373 case 1:
6374 case 2:
6375 case 3:
6376 case 4:
6377 case 5:
6378 case 6:
6379 {
6380 //This gets a render target.
6381 destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
6382 break;
6383 }
6384 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
6385 default:
6386 {
6387 auto& usr_bitmap = scb.get(usr_bitmap_index);
6388 destBMP = usr_bitmap.u_bmp;
6389 if ( !usr_bitmap.u_bmp )
6390 {
6391 Z_scripterrlog("Target for bitmap->DrawPlane is uninitialised. Aborting.\n");
6392 break;
6393 }
6394 }
6395 }
6396
6397 if (!destBMP)
6398 {
6399 Z_message("Warning: DrawPlane(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
6400 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6401 return;
6402 }
6403
6404 //dx = dx + xoffset; //don't do this here!
6405 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
6406 //All of these are a factor of 10000 as fix.
6407 int32_t screen_x = 0; int32_t screen_y = 0;
6408
6409 double distance = 0; double horizontal_scale = 0;
6410
6411 int32_t screen_y_horizon = 0;
6412
6413 double line_dx = 0; double line_dy = 0;
6414
6415 int32_t space_x = 0; int32_t space_y = 0;
6416
6417 for(screen_y = 0; screen_y < destH; screen_y++) //fix, offset by .0000
6418 {
6419 //Calculate the distance of each line from the camera point
6420 screen_y_horizon = screen_y + horizon;
6421
6422 distance = ((space_z * scale_y) / ((screen_y_horizon != 0) ? screen_y_horizon : 1));
6423
6424 //Get the scale of each line based on the distance
6425
6426 horizontal_scale = (distance / (( scale_x != 0 ) ? scale_x : 1));
6427
6428 //There was some math here before I stripped out the rotation step
6429 line_dx = horizontal_scale;
6430 line_dy = 0;
6431
6432 //space_x,space_y - where to grab each scanline from on the space bitmap
6433 space_x = srcX - destW/2.0 * line_dx;
6434 space_y = srcY - distance + destH/2.0 * line_dy;
6435
6436 //Keep blits within the bounds of both bitmaps to avoid crashes
6437 int32_t y1 = srcY+space_y;
6438 int32_t y2 = destY+screen_y;
6439 if(y1 >=0 && y1 <= (sourceBitmap->h-1) && y2 >=0 && y2 <= (destBMP->h-1) )
6440 {
6441 if ( masked ) masked_stretch_blit(sourceBitmap, destBMP, (int32_t)(srcX+space_x), (int32_t)(srcY+space_y),
6442 (int32_t)(line_dx*destW), 1, (int32_t)(screen_x), (int32_t)(screen_y)+yoffset, (int32_t)(destW), 1);
6443 else stretch_blit(sourceBitmap, destBMP, (int32_t)(srcX+space_x), (int32_t)(srcY+space_y),
6444 (int32_t)(line_dx*destW), 1, (int32_t)(screen_x), (int32_t)(screen_y)+yoffset, (int32_t)(destW), 1);
6445 }
6446 }
6447 }
6448
6449
6450 //Draw]()
6451 2062708 void bmp_do_drawbitmapexr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
6452 {
6453 /*
6454 //sdci[1]=layer
6455 //sdci[2]=bitmap target
6456 //
6457 // -2 is the current Render Target
6458 // -1, this is the screen (framebuf).
6459 // 0: Render target 0
6460 // 1: Render target 1
6461 // 2: Render target 2
6462 // 3: Render target 3
6463 // 4: Render target 4
6464 // 5: Render target 5
6465 // 6: Render target 6
6466 // Otherwise: The pointer to a bitmap.
6467
6468 //sdci[3]=sourcex
6469 //sdci[4]=sourcey
6470 //sdci[5]=sourcew
6471 //sdci[6]=sourceh
6472 //sdci[7]=destx
6473 //sdci[8]=desty
6474 //sdci[9]=destw
6475 //sdci[10]=desth
6476 //sdci[11]=rotation/angle
6477 //scdi[12] = pivot cx
6478 //sdci[13] = pivot cy
6479 //scdi[14] = effect flags
6480 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
6481
6482 // ZScript-side constant values:
6483 const int32_t BITDX_NORMAL = 0;
6484 const int32_t BITDX_TRANS = 1; //Translucent
6485 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
6486 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
6487 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
6488 //Note: Some modes cannot be combined. if a combination is not supported, an error
6489 // detailing this will be shown in allegro.log.
6490
6491 //scdi[15] = litcolour
6492 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6493 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
6494
6495 //sdci[16]=mask
6496
6497 */
6498
6499 2062708 int32_t usr_bitmap_index = sdci[2];
6500 4125416 auto [bitmapIndex, is_user_bitmap] = resolveScriptingBitmapId(usr_bitmap_index);
6501
6502
6503 2062708 int32_t sx = sdci[3]/10000;
6504 2062708 int32_t sy = sdci[4]/10000;
6505 2062708 int32_t sw = sdci[5]/10000;
6506 2062708 int32_t sh = sdci[6]/10000;
6507 2062708 int32_t dx = sdci[7]/10000;
6508 2062708 int32_t dy = sdci[8]/10000;
6509 2062708 int32_t dw = sdci[9]/10000;
6510 2062708 int32_t dh = sdci[10]/10000;
6511 2062708 float rot = sdci[11]/10000;
6512 2062708 int32_t cx = sdci[12]/10000;
6513 2062708 int32_t cy = sdci[13]/10000;
6514 2062708 int32_t mode = sdci[14]/10000;
6515 2062708 int32_t litcolour = sdci[15]/10000;
6516 2062708 bool masked = (sdci[16] != 0);
6517
6518 2062708 int32_t ref = 0;
6519
6520
2/2
✓ Branch 0 taken 267486 times.
✓ Branch 1 taken 1795222 times.
2062708 if (get_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN))
6521 {
6522
2/2
✓ Branch 0 taken 95143 times.
✓ Branch 1 taken 172343 times.
267486 if (is_user_bitmap)
6523 172343 yoffset = 0;
6524
6525 267486 dx += xoffset;
6526 267486 dy += yoffset;
6527 267486 }
6528 else
6529 {
6530 1795222 dx += secondary_draw_origin_xoff;
6531 1795222 dy += secondary_draw_origin_yoff;
6532
6533 1795222 sx += xoffset;
6534 1795222 sy += yoffset;
6535 }
6536
6537 2062708 ref = sdci[DRAWCMD_BMP_TARGET];
6538
6539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2062708 times.
2062708 if ( ref <= 0 )
6540 {
6541 Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
6542 return;
6543 }
6544 2062708 BITMAP *sourceBitmap = resolveScriptingBitmap(ref); //This can be the screen, as -1.
6545
6546
1/2
✓ Branch 0 taken 2062708 times.
✗ Branch 1 not taken.
2062708 if(!sourceBitmap)
6547 {
6548
6549 Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref);
6550 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6551 return;
6552 }
6553
6554 2062708 BITMAP *destBMP=NULL;
6555
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 224018 times.
✓ Branch 2 taken 14218 times.
✓ Branch 3 taken 1824472 times.
2062708 switch(bitmapIndex)
6556 {
6557 // Current render target (RT_CURRENT).
6558 // This is the only reason we aren't using resolveScriptingBitmap for the target bitmap. All the other cases should be equivalent.
6559 case -2:
6560 {
6561 14218 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
6562
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 14218 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
14218 if ( curr_rt >= 0 && curr_rt < 7 )
6563 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
6564 14218 else destBMP = bmp; //screen
6565 14218 break;
6566 }
6567 case -1:
6568 1824472 destBMP = bmp; //this is framebuf, by default
6569 1824472 break;
6570 //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex);
6571 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
6572 //destBMP = framebuf; //Drawing to the screen.
6573 //break;
6574
6575 //1 through 6 are the old system bitmaps (Render Targets)
6576 case 0:
6577 case 1:
6578 case 2:
6579 case 3:
6580 case 4:
6581 case 5:
6582 case 6:
6583 {
6584 //This gets a render target.
6585 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break;
6586
6587 //destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
6588 //sdci[18] = bitmapIndex;
6589 break;
6590 }
6591 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
6592 default:
6593 {
6594 224018 auto& usr_bitmap = scb.get(usr_bitmap_index);
6595 224018 destBMP = usr_bitmap.u_bmp;
6596 //sdci[18] = usr_bitmap_index;
6597
1/2
✓ Branch 0 taken 224018 times.
✗ Branch 1 not taken.
224018 if ( !usr_bitmap.u_bmp )
6598 {
6599 Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n");
6600 break;
6601 }
6602 }
6603 224018 }
6604
6605
1/2
✓ Branch 0 taken 2062708 times.
✗ Branch 1 not taken.
2062708 if (!destBMP)
6606 {
6607 Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
6608 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
6609 return;
6610 }
6611
6612
2/2
✓ Branch 0 taken 1511 times.
✓ Branch 1 taken 2061197 times.
2062708 bool stretched = (sw != dw || sh != dh);
6613 2062708 BITMAP* subBmp = 0;
6614
6615
4/4
✓ Branch 0 taken 2061129 times.
✓ Branch 1 taken 1579 times.
✓ Branch 2 taken 25732 times.
✓ Branch 3 taken 2035397 times.
2062708 if(rot != 0 || mode != 0)
6616 {
6617 27311 subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
6618 27311 clear_bitmap(subBmp);
6619
6620
1/2
✓ Branch 0 taken 27311 times.
✗ Branch 1 not taken.
27311 if(!subBmp)
6621 {
6622
6623 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
6624 return;
6625 }
6626 27311 }
6627 2062708 BITMAP* sbmp = sourceBitmap;
6628
3/4
✓ Branch 0 taken 2061946 times.
✓ Branch 1 taken 762 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2061946 times.
2062708 if (sx + sw > sbmp->w || sy + sh > sbmp->h)
6629 {
6630 762 sbmp = create_bitmap_ex(8, sw, sh);
6631 762 clear_bitmap(sbmp);
6632 762 blit(sourceBitmap, sbmp, sx, sy, 0, 0, std::min(sourceBitmap->w-sx, sw), std::min(sourceBitmap->h-sy, sh));
6633 762 sx = 0;
6634 762 sy = 0;
6635 762 }
6636 //dx = dx + xoffset; //don't do this here!
6637 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
6638
6639
2/2
✓ Branch 0 taken 2086 times.
✓ Branch 1 taken 2060622 times.
2062708 if(stretched)
6640 {
6641
2/2
✓ Branch 0 taken 1475 times.
✓ Branch 1 taken 611 times.
2086 if(masked)
6642 { //stretched and masked
6643
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 901 times.
1475 if ( rot == 0 )
6644 { //if not rotated
6645
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 900 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1 times.
901 switch(mode)
6646 {
6647 case 1:
6648 //transparent
6649 900 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6650 900 draw_trans_sprite(destBMP, subBmp, dx, dy);
6651 900 break;
6652
6653
6654 case 2:
6655 //pivot?
6656 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6657 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6658 //Pivoting requires two more args
6659 break;
6660
6661 case 3:
6662 //pivot + trans
6663 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6664 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6665 break;
6666
6667 case 4:
6668 //flip v
6669 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6670 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
6671 break;
6672
6673 case 5:
6674 //trans + v flip
6675 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6676 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
6677 break;
6678
6679 case 6:
6680 //pivot + v flip
6681 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6682 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6683 break;
6684
6685 case 8:
6686 //vlip h
6687 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6688 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
6689 break;
6690
6691 case 9:
6692 //trans + h flip
6693 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6694 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
6695 break;
6696
6697 case 10:
6698 //flip H and pivot
6699 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6700 //return error cannot pivot and h flip
6701 break;
6702
6703 case 12:
6704 //vh flip
6705 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6706 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
6707 break;
6708
6709 case 13:
6710 //trans + vh flip
6711 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6712 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
6713 break;
6714
6715 case 14:
6716 //pivot and vh flip
6717 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
6718 //return error cannot both pivot and vh flip
6719 break;
6720
6721 case 16:
6722 //lit
6723 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6724 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
6725 break;
6726
6727 case 18:
6728 //pivot, lit
6729 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6730 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
6731 break;
6732
6733 case 20:
6734 //lit + v flip
6735 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6736 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
6737 break;
6738
6739 case 22:
6740 //Pivot, vflip, lit
6741 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6742 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
6743 break;
6744
6745 case 24:
6746 //lit + h flip
6747 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6748 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
6749 break;
6750
6751 case 26:
6752 //pivot + lit + hflip
6753 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
6754 //return error cannot pivot, lit, and flip
6755 break;
6756
6757 case 28:
6758 //lit + vh flip
6759 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6760 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
6761 break;
6762
6763 case 32: //gouraud
6764 //Probably not wort supporting.
6765 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6766 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
6767 break;
6768
6769 case 0:
6770 //no effect
6771 1 masked_stretch_blit(sbmp, destBMP, sx, sy, sw, sh, dx, dy, dw, dh);
6772 1 break;
6773
6774
6775 default:
6776
6777 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
6778
6779
6780 }
6781 901 } //end if not rotated
6782
6783
2/2
✓ Branch 0 taken 901 times.
✓ Branch 1 taken 574 times.
1475 if ( rot != 0 ) //if rotated
6784 {
6785
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 574 times.
✗ Branch 21 not taken.
574 switch(mode)
6786 {
6787 case 1:
6788 //transparent
6789 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6790 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6791
6792 break;
6793
6794 case 2:
6795 //pivot?
6796 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6797 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6798 //Pivoting requires two more args
6799 break;
6800
6801 case 3:
6802 //pivot + trans
6803 //return an error, cannot both rotate and pivot
6804 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6805 break;
6806
6807 case 4:
6808 //flip v
6809 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6810 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6811 break;
6812
6813 case 5:
6814 //trans + v flip
6815 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6816 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6817 break;
6818
6819 case 6:
6820 //pivot + v flip
6821 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6822 //return an error, cannot both rotate and pivot
6823 break;
6824
6825 case 8:
6826 //flip h
6827 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
6828 //return an error, cannot both rotate and flip H
6829 break;
6830
6831 case 9:
6832 //trans + h flip
6833 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
6834 //return an error, cannot rotate and flip a trans sprite
6835 break;
6836
6837 case 10:
6838 //flip H and pivot
6839 //return error cannot pivot and h flip
6840 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6841 break;
6842
6843 case 12:
6844 //vh flip
6845 //return an error, cannot rotate and VH flip a trans sprite
6846 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
6847 break;
6848
6849 case 13:
6850 //trans + vh flip
6851 //return an error, cannot rotate and VH flip a trans sprite
6852 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
6853 break;
6854
6855 case 14:
6856 //pivot and vh flip
6857 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
6858 //return error cannot both pivot and vh flip
6859 break;
6860
6861 case 16:
6862 //lit
6863 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6864 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6865 break;
6866
6867 case 18:
6868 //pivot, lit
6869 //return an error, cannot both rotate and pivot
6870 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
6871 break;
6872
6873 case 20:
6874 //lit + vflip
6875 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6876 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
6877 break;
6878
6879 case 22:
6880 //Pivot, vflip, lit
6881 //return an error, cannot both rotate and pivot
6882 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
6883 break;
6884
6885 case 24:
6886 //lit + h flip
6887 //return an error, cannot both rotate and H flip
6888 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
6889 break;
6890
6891 case 26:
6892 //pivot + lit + hflip
6893 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
6894 //return error cannot pivot, lit, and flip
6895 break;
6896
6897 case 28:
6898 //lit + vh flip
6899 //return an error, cannot both rotate and VH flip
6900 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
6901 break;
6902
6903 case 32: //gouraud
6904 //Probably not wort supporting.
6905 //masked_stretch_blit(sourceBitmap, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6906 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
6907 break;
6908
6909 case 0:
6910 //no effect.
6911 574 masked_stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6912 574 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
6913 574 break;
6914
6915 default:
6916
6917 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
6918
6919 }
6920 574 }
6921 1475 } //end if stretched and masked
6922
6923 else //stretched, not masked
6924 {
6925
6926
6927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 611 times.
611 if ( rot == 0 ) //if not rotated
6928 {
6929
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 611 times.
611 switch(mode)
6930 {
6931 case 1:
6932 //transparent
6933 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6934 draw_trans_sprite(destBMP, subBmp, dx, dy);
6935 break;
6936
6937
6938 case 2:
6939 //pivot?
6940 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6941 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6942 //Pivoting requires two more args
6943 break;
6944
6945 case 3:
6946 //pivot + trans
6947 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6948 pivot_sprite_trans(destBMP, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
6949 break;
6950
6951 case 4:
6952 //flip v
6953 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6954 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
6955 break;
6956
6957 case 5:
6958 //trans + v flip
6959 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6960 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
6961 break;
6962
6963 case 6:
6964 //pivot + v flip
6965 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6966 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
6967 break;
6968
6969 case 8:
6970 //vlip h
6971 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6972 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
6973 break;
6974
6975 case 9:
6976 //trans + h flip
6977 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6978 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
6979 break;
6980
6981 case 10:
6982 //flip H and pivot
6983 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
6984 //return error cannot pivot and h flip
6985 break;
6986
6987 case 12:
6988 //vh flip
6989 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6990 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
6991 break;
6992
6993 case 13:
6994 //trans + vh flip
6995 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
6996 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
6997 break;
6998
6999 case 14:
7000 //pivot and vh flip
7001 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7002 //return error cannot both pivot and vh flip
7003 break;
7004
7005 case 16:
7006 //lit
7007 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7008 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7009 break;
7010
7011 case 18:
7012 //pivot, lit
7013 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7014 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7015 break;
7016
7017 case 20:
7018 //lit + v flip
7019 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7020 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7021 break;
7022
7023 case 22:
7024 //Pivot, vflip, lit
7025 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7026 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7027 break;
7028
7029 case 24:
7030 //lit + h flip
7031 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7032 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7033 break;
7034
7035 case 26:
7036 //pivot + lit + hflip
7037 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7038 //return error cannot pivot, lit, and flip
7039 break;
7040
7041 case 28:
7042 //lit + vh flip
7043 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7044 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7045 break;
7046
7047 case 32: //gouraud
7048 //Probably not wort supporting.
7049 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7050 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7051 break;
7052
7053 case 0:
7054 //no effect
7055 611 stretch_blit(sbmp, destBMP, sx, sy, sw, sh, dx, dy, dw, dh);
7056 611 break;
7057
7058
7059 default:
7060
7061 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7062
7063
7064 }
7065 611 } //end if not rotated
7066
7067
1/2
✓ Branch 0 taken 611 times.
✗ Branch 1 not taken.
611 if ( rot != 0 ) //if rotated
7068 {
7069 switch(mode)
7070 {
7071 case 1:
7072 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7073 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7074
7075 break;
7076
7077 case 2:
7078 //pivot?
7079 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7080 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7081 //Pivoting requires two more args
7082 break;
7083
7084 case 3:
7085 //pivot + trans
7086 //return an error, cannot both rotate and pivot
7087 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7088 break;
7089
7090 case 4:
7091 //flip v
7092 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7093 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7094 break;
7095
7096 case 5:
7097 //trans + v flip
7098 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7099 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7100 break;
7101
7102 case 6:
7103 //pivot + v flip
7104 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7105 //return an error, cannot both rotate and pivot
7106 break;
7107
7108 case 8:
7109 //flip h
7110 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7111 //return an error, cannot both rotate and flip H
7112 break;
7113
7114 case 9:
7115 //trans + h flip
7116 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7117 //return an error, cannot rotate and flip a trans sprite
7118 break;
7119
7120 case 10:
7121 //flip H and pivot
7122 //return error cannot pivot and h flip
7123 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7124 break;
7125
7126 case 12:
7127 //vh flip
7128 //return an error, cannot rotate and VH flip a trans sprite
7129 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7130 break;
7131
7132 case 13:
7133 //trans + vh flip
7134 //return an error, cannot rotate and VH flip a trans sprite
7135 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7136 break;
7137
7138 case 14:
7139 //pivot and vh flip
7140 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7141 //return error cannot both pivot and vh flip
7142 break;
7143
7144 case 16:
7145 //lit
7146 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7147 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7148 break;
7149
7150 case 18:
7151 //pivot, lit
7152 //return an error, cannot both rotate and pivot
7153 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7154 break;
7155
7156 case 20:
7157 //lit + vflip
7158 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
7159 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7160 break;
7161
7162 case 22:
7163 //Pivot, vflip, lit
7164 //return an error, cannot both rotate and pivot
7165 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7166 break;
7167
7168 case 24:
7169 //lit + h flip
7170 //return an error, cannot both rotate and H flip
7171 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7172 break;
7173
7174 case 26:
7175 //pivot + lit + hflip
7176 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7177 //return error cannot pivot, lit, and flip
7178 break;
7179
7180 case 28:
7181 //lit + vh flip
7182 //return an error, cannot both rotate and VH flip
7183 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7184 break;
7185
7186 case 32: //gouraud
7187 //Probably not wort supporting.
7188 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7189 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7190 break;
7191
7192 case 0:
7193 //no effect.
7194 stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7195 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7196 break;
7197
7198 default:
7199
7200 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7201
7202 }
7203 }
7204
7205 } //end if stretched, but not masked
7206 2086 }
7207 else //not stretched
7208 {
7209
7210
2/2
✓ Branch 0 taken 1982848 times.
✓ Branch 1 taken 77774 times.
2060622 if(masked) //if masked, but not stretched
7211 {
7212
7213
2/2
✓ Branch 0 taken 1005 times.
✓ Branch 1 taken 1981843 times.
1982848 if ( rot == 0 ) //if not rotated
7214 {
7215
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 19118 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 1962725 times.
1981843 switch(mode)
7216 {
7217 case 1:
7218 //transparent
7219 19118 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7220 19118 draw_trans_sprite(destBMP, subBmp, dx, dy);
7221 19118 break;
7222
7223
7224 case 2:
7225 //pivot?
7226 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7227 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7228 //Pivoting requires two more args
7229 break;
7230
7231 case 3:
7232 //pivot + trans
7233 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7234 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7235 break;
7236
7237 case 4:
7238 //flip v
7239 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7240 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
7241 break;
7242
7243 case 5:
7244 //trans + v flip
7245 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7246 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
7247 break;
7248
7249 case 6:
7250 //pivot + v flip
7251 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7252 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7253 break;
7254
7255 case 8:
7256 //vlip h
7257 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7258 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
7259 break;
7260
7261 case 9:
7262 //trans + h flip
7263 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7264 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
7265 break;
7266
7267 case 10:
7268 //flip H and pivot
7269 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7270 //return error cannot pivot and h flip
7271 break;
7272
7273 case 12:
7274 //vh flip
7275 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7276 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7277 break;
7278
7279 case 13:
7280 //trans + vh flip
7281 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7282 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7283 break;
7284
7285 case 14:
7286 //pivot and vh flip
7287 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7288 //return error cannot both pivot and vh flip
7289 break;
7290
7291 case 16:
7292 //lit
7293 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7294 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7295 break;
7296
7297 case 18:
7298 //pivot, lit
7299 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7300 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7301 break;
7302
7303 case 20:
7304 //lit + v flip
7305 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7306 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7307 break;
7308
7309 case 22:
7310 //Pivot, vflip, lit
7311 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7312 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7313 break;
7314
7315 case 24:
7316 //lit + h flip
7317 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7318 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7319 break;
7320
7321 case 26:
7322 //pivot + lit + hflip
7323 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7324 //return error cannot pivot, lit, and flip
7325 break;
7326
7327 case 28:
7328 //lit + vh flip
7329 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7330 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7331 break;
7332
7333 case 32: //gouraud
7334 //Probably not wort supporting.
7335 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7336 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7337 break;
7338
7339 case 0:
7340 //no effect
7341 1962725 masked_blit(sbmp, destBMP, sx, sy, dx, dy, dw, dh);
7342 1962725 break;
7343
7344
7345 default:
7346
7347 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7348
7349
7350 }
7351 1981843 } //end if not rotated
7352
7353
2/2
✓ Branch 0 taken 1981843 times.
✓ Branch 1 taken 1005 times.
1982848 if ( rot != 0 ) //if rotated
7354 {
7355
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✓ Branch 20 taken 1005 times.
✗ Branch 21 not taken.
1005 switch(mode)
7356 {
7357 case 1:
7358 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); //transparent
7359 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7360
7361 break;
7362
7363 case 2:
7364 //pivot?
7365 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7366 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7367 //Pivoting requires two more args
7368 break;
7369
7370 case 3:
7371 //pivot + trans
7372 //return an error, cannot both rotate and pivot
7373 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7374 break;
7375
7376 case 4:
7377 //flip v
7378 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7379 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7380 break;
7381
7382 case 5:
7383 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
7384 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7385 break;
7386
7387 case 6:
7388 //pivot + v flip
7389 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7390 //return an error, cannot both rotate and pivot
7391 break;
7392
7393 case 8:
7394 //flip h
7395 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7396 //return an error, cannot both rotate and flip H
7397 break;
7398
7399 case 9:
7400 //trans + h flip
7401 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7402 //return an error, cannot rotate and flip a trans sprite
7403 break;
7404
7405 case 10:
7406 //flip H and pivot
7407 //return error cannot pivot and h flip
7408 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7409 break;
7410
7411 case 12:
7412 //vh flip
7413 //return an error, cannot rotate and VH flip a trans sprite
7414 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7415 break;
7416
7417 case 13:
7418 //trans + vh flip
7419 //return an error, cannot rotate and VH flip a trans sprite
7420 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7421 break;
7422
7423 case 14:
7424 //pivot and vh flip
7425 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7426 //return error cannot both pivot and vh flip
7427 break;
7428
7429 case 16:
7430 //lit
7431 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7432 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7433 break;
7434
7435 case 18:
7436 //pivot, lit
7437 //return an error, cannot both rotate and pivot
7438 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7439 break;
7440
7441 case 20:
7442 //lit + vflip
7443 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7444 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7445 break;
7446
7447 case 22:
7448 //Pivot, vflip, lit
7449 //return an error, cannot both rotate and pivot
7450 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7451 break;
7452
7453 case 24:
7454 //lit + h flip
7455 //return an error, cannot both rotate and H flip
7456 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7457 break;
7458
7459 case 26:
7460 //pivot + lit + hflip
7461 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7462 //return error cannot pivot, lit, and flip
7463 break;
7464
7465 case 28:
7466 //lit + vh flip
7467 //return an error, cannot both rotate and VH flip
7468 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7469 break;
7470
7471 case 32: //gouraud
7472 //Probably not wort supporting.
7473 //stretch_blit(sbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7474 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7475 break;
7476
7477 case 0:
7478 //no effect.
7479 1005 masked_blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7480 1005 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7481 1005 break;
7482
7483 default:
7484
7485 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7486
7487 }
7488 1005 } //end rtated, masked
7489 1982848 } //end if masked
7490
7491 else //not masked, and not stretched; just blit
7492 {
7493
7494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 77774 times.
77774 if ( rot == 0 ) //if not rotated
7495 {
7496
2/22
✗ Branch 0 not taken.
✓ Branch 1 taken 5714 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 72060 times.
77774 switch(mode)
7497 {
7498 case 1:
7499 //transparent
7500 5714 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7501 5714 draw_trans_sprite(destBMP, subBmp, dx, dy);
7502 5714 break;
7503
7504
7505 case 2:
7506 //pivot?
7507 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7508 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7509 //Pivoting requires two more args
7510 break;
7511
7512 case 3:
7513 //pivot + trans
7514 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7515 pivot_sprite_trans(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7516 break;
7517
7518 case 4:
7519 //flip v
7520 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7521 draw_sprite_v_flip(destBMP, subBmp, dx, dy);
7522 break;
7523
7524 case 5:
7525 //trans + v flip
7526 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7527 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
7528 break;
7529
7530 case 6:
7531 //pivot + v flip
7532 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7533 pivot_sprite_v_flip(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7534 break;
7535
7536 case 8:
7537 //vlip h
7538 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7539 draw_sprite_h_flip(destBMP, subBmp, dx, dy);
7540 break;
7541
7542 case 9:
7543 //trans + h flip
7544 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7545 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
7546 break;
7547
7548 case 10:
7549 //flip H and pivot
7550 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7551 //return error cannot pivot and h flip
7552 break;
7553
7554 case 12:
7555 //vh flip
7556 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7557 draw_sprite_vh_flip(destBMP, subBmp, dx, dy);
7558 break;
7559
7560 case 13:
7561 //trans + vh flip
7562 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7563 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
7564 break;
7565
7566 case 14:
7567 //pivot and vh flip
7568 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7569 //return error cannot both pivot and vh flip
7570 break;
7571
7572 case 16:
7573 //lit
7574 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7575 draw_lit_sprite(destBMP, subBmp, dx, dy, litcolour);
7576 break;
7577
7578 case 18:
7579 //pivot, lit
7580 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7581 pivot_sprite_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7582 break;
7583
7584 case 20:
7585 //lit + v flip
7586 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7587 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
7588 break;
7589
7590 case 22:
7591 //Pivot, vflip, lit
7592 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7593 pivot_sprite_v_flip_lit(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
7594 break;
7595
7596 case 24:
7597 //lit + h flip
7598 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7599 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
7600 break;
7601
7602 case 26:
7603 //pivot + lit + hflip
7604 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
7605 //return error cannot pivot, lit, and flip
7606 break;
7607
7608 case 28:
7609 //lit + vh flip
7610 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7611 draw_sprite_ex(destBMP, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
7612 break;
7613
7614 case 32: //gouraud
7615 //Probably not wort supporting.
7616 //blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7617 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7618 break;
7619
7620 case 0:
7621 //no effect
7622 72060 blit(sbmp, destBMP, sx, sy, dx, dy, dw, dh);
7623 72060 break;
7624
7625
7626 default:
7627
7628 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7629
7630
7631 }
7632 77774 } //end if not rotated
7633
7634
1/2
✓ Branch 0 taken 77774 times.
✗ Branch 1 not taken.
77774 if ( rot != 0 ) //if rotated
7635 {
7636 switch(mode)
7637 {
7638 case 1:
7639 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);//transparent
7640 rotate_sprite_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7641
7642 break;
7643
7644 case 2:
7645 //pivot?
7646 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7647 pivot_sprite(destBMP, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
7648 //Pivoting requires two more args
7649 break;
7650
7651 case 3:
7652 //pivot + trans
7653 //return an error, cannot both rotate and pivot
7654 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7655 break;
7656
7657 case 4:
7658 //flip v
7659 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7660 rotate_sprite_v_flip(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7661 break;
7662
7663 case 5:
7664 //trans + v flip
7665 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7666 rotate_sprite_v_flip_trans(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7667 break;
7668
7669 case 6:
7670 //pivot + v flip
7671 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7672 //return an error, cannot both rotate and pivot
7673 break;
7674
7675 case 8:
7676 //flip h
7677 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
7678 //return an error, cannot both rotate and flip H
7679 break;
7680
7681 case 9:
7682 //trans + h flip
7683 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
7684 //return an error, cannot rotate and flip a trans sprite
7685 break;
7686
7687 case 10:
7688 //flip H and pivot
7689 //return error cannot pivot and h flip
7690 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
7691 break;
7692
7693 case 12:
7694 //vh flip
7695 //return an error, cannot rotate and VH flip a trans sprite
7696 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7697 break;
7698
7699 case 13:
7700 //trans + vh flip
7701 //return an error, cannot rotate and VH flip a trans sprite
7702 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
7703 break;
7704
7705 case 14:
7706 //pivot and vh flip
7707 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7708 //return error cannot both pivot and vh flip
7709 break;
7710
7711 case 16:
7712 //lit
7713 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7714 rotate_sprite_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7715 break;
7716
7717 case 18:
7718 //pivot, lit
7719 //return an error, cannot both rotate and pivot
7720 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
7721 break;
7722
7723 case 20:
7724 //lit + vflip
7725 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7726 rotate_sprite_v_flip_lit(destBMP, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7727 break;
7728
7729 case 22:
7730 //Pivot, vflip, lit
7731 //return an error, cannot both rotate and pivot
7732 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
7733 break;
7734
7735 case 24:
7736 //lit + h flip
7737 //return an error, cannot both rotate and H flip
7738 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
7739 break;
7740
7741 case 26:
7742 //pivot + lit + hflip
7743 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
7744 //return error cannot pivot, lit, and flip
7745 break;
7746
7747 case 28:
7748 //lit + vh flip
7749 //return an error, cannot both rotate and VH flip
7750 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
7751 break;
7752
7753 case 32: //gouraud
7754 //Probably not wort supporting.
7755 //blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7756 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
7757 break;
7758
7759 case 0:
7760 //no effect.
7761 blit(sbmp, subBmp, sx, sy, 0, 0, dw, dh);
7762 rotate_sprite(destBMP, subBmp, dx, dy, degrees_to_fixed(rot));
7763 break;
7764
7765 default:
7766
7767 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
7768
7769 }
7770 } //end if rotated
7771 } //end if not masked
7772 } //end if not stretched
7773
7774 //cleanup
7775
2/2
✓ Branch 0 taken 27311 times.
✓ Branch 1 taken 2035397 times.
2062708 if(subBmp)
7776 {
7777 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
7778 27311 destroy_bitmap(subBmp);
7779 27311 }
7780
2/2
✓ Branch 0 taken 762 times.
✓ Branch 1 taken 2061946 times.
2062708 if (sbmp != sourceBitmap)
7781 {
7782 762 destroy_bitmap(sbmp);
7783 762 }
7784 2062708 }
7785
7786
7787
7788 113653 void bmp_do_blittor(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset)
7789 {
7790 /*
7791 //sdci[1]=layer
7792 //sdci[2]=bitmap target
7793 //
7794 // -2 is the current Render Target
7795 // -1, this is the screen (framebuf).
7796 // 0: Render target 0
7797 // 1: Render target 1
7798 // 2: Render target 2
7799 // 3: Render target 3
7800 // 4: Render target 4
7801 // 5: Render target 5
7802 // 6: Render target 6
7803 // Otherwise: The pointer to a bitmap.
7804
7805 //sdci[3]=sourcex
7806 //sdci[4]=sourcey
7807 //sdci[5]=sourcew
7808 //sdci[6]=sourceh
7809 //sdci[7]=destx
7810 //sdci[8]=desty
7811 //sdci[9]=destw
7812 //sdci[10]=desth
7813 //sdci[11]=rotation/angle
7814 //scdi[12] = pivot cx
7815 //sdci[13] = pivot cy
7816 //scdi[14] = effect flags
7817 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
7818
7819 // ZScript-side constant values:
7820 const int32_t BITDX_NORMAL = 0;
7821 const int32_t BITDX_TRANS = 1; //Translucent
7822 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
7823 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
7824 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
7825 //Note: Some modes cannot be combined. if a combination is not supported, an error
7826 // detailing this will be shown in allegro.log.
7827
7828 //scdi[15] = litcolour
7829 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
7830 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
7831
7832 //sdci[16]=mask
7833
7834 */
7835
7836 113653 int32_t srcyoffset = yoffset, srcxoffset = xoffset;
7837
7838 113653 int32_t usr_bitmap_index = sdci[2];
7839 340955 auto [bitmapIndex, is_user_bitmap] = resolveScriptingBitmapId(usr_bitmap_index);
7840
7841 113653 int32_t sx = sdci[3]/10000;
7842 113653 int32_t sy = sdci[4]/10000;
7843 113653 int32_t sw = sdci[5]/10000;
7844 113653 int32_t sh = sdci[6]/10000;
7845 113653 int32_t dx = sdci[7]/10000;
7846 113653 int32_t dy = sdci[8]/10000;
7847 113653 int32_t dw = sdci[9]/10000;
7848 113653 int32_t dh = sdci[10]/10000;
7849 113653 float rot = sdci[11]/10000;
7850 113653 int32_t cx = sdci[12]/10000;
7851 113653 int32_t cy = sdci[13]/10000;
7852 113653 int32_t mode = sdci[14]/10000;
7853 113653 int32_t litcolour = sdci[15]/10000;
7854 113653 bool masked = (sdci[16] != 0);
7855
7856 113653 int32_t ref = 0;
7857
7858
2/2
✓ Branch 0 taken 113649 times.
✓ Branch 1 taken 4 times.
113653 if (get_qr(qr_BROKEN_SCRIPTS_BITMAP_DRAW_ORIGIN))
7859 {
7860
2/2
✓ Branch 0 taken 263 times.
✓ Branch 1 taken 113386 times.
113649 if (is_user_bitmap)
7861 113386 srcyoffset = 0;
7862
2/4
✓ Branch 0 taken 113649 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113649 times.
113649 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
7863
3/4
✓ Branch 0 taken 113649 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 113646 times.
113649 if ( (bitmapIndex) != -2 && (bitmapIndex) != -1 ) srcyoffset = 0; //Don't crop.
7864
7865 113649 dx += xoffset;
7866 113649 dy += yoffset;
7867
7868 113649 sx += srcxoffset;
7869 113649 sy += srcyoffset;
7870 113649 }
7871 else
7872 {
7873 4 dx += xoffset;
7874 4 dy += yoffset;
7875
7876 4 sx += secondary_draw_origin_xoff;
7877 4 sy += secondary_draw_origin_yoff;
7878 }
7879
7880 113653 ref = sdci[DRAWCMD_BMP_TARGET];
7881
7882
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113653 times.
113653 if ( ref <= 0 )
7883 {
7884 Z_scripterrlog("bitmap->blit() wanted to use to an invalid source bitmap id: %d. Aborting.\n", ref);
7885 return;
7886 }
7887 113653 BITMAP *sourceBitmap = resolveScriptingBitmap(ref); //This can be the screen, as -1.
7888
1/2
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
113653 if(!sourceBitmap)
7889 {
7890 Z_message("Warning: blit(%d) source bitmap contains invalid data or is not initialized.\n", ref);
7891 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
7892 return;
7893 }
7894
7895 113653 BITMAP *destBMP=NULL;
7896
7897
3/4
✓ Branch 0 taken 260 times.
✓ Branch 1 taken 113386 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
113653 switch(bitmapIndex)
7898 {
7899 // Current render target (RT_CURRENT).
7900 // This is the only reason we aren't using resolveScriptingBitmap for the target bitmap. All the other cases should be equivalent.
7901 case -2:
7902 {
7903 int32_t curr_rt = zscriptDrawingRenderTarget->GetCurrentRenderTarget();
7904 if ( curr_rt >= 0 && curr_rt < 7 )
7905 destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); //Drawing to the current RenderTarget.
7906 else destBMP = bmp; //screen
7907 break;
7908 }
7909 case -1:
7910 7 destBMP = bmp; //this is framebuf, by default
7911 7 break;
7912 //zscriptDrawingRenderTarget->SetCurrentRenderTarget(bitmapIndex);
7913 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex);
7914 //destBMP = framebuf; //Drawing to the screen.
7915 //break;
7916
7917 //1 through 6 are the old system bitmaps (Render Targets)
7918 case 0:
7919 case 1:
7920 case 2:
7921 case 3:
7922 case 4:
7923 case 5:
7924 case 6:
7925 {
7926 //This gets a render target.
7927 //destBMP = zscriptDrawingRenderTarget->GetBitmapPtr(bitmapIndex); break;
7928
7929 520 destBMP = zscriptDrawingRenderTarget->GetTargetBitmap(bitmapIndex);
7930 //sdci[18] = bitmapIndex;
7931 260 break;
7932 }
7933 //Otherwise, we are using a user-created bitmap, so, get that pointer insted.
7934 default:
7935 {
7936 113386 auto& usr_bitmap = scb.get(usr_bitmap_index);
7937 113386 destBMP = usr_bitmap.u_bmp;
7938 //sdci[18] = usr_bitmap_index;
7939
1/2
✓ Branch 0 taken 113386 times.
✗ Branch 1 not taken.
113386 if ( !usr_bitmap.u_bmp )
7940 {
7941 Z_scripterrlog("Target for bitmap->Blit is uninitialised. Aborting.\n");
7942 break;
7943 }
7944 }
7945 113386 }
7946
7947
1/2
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
113653 if (!destBMP)
7948 {
7949 Z_message("Warning: blit(%d) destination bitmap contains invalid data or is not initialized.\n", bitmapIndex);
7950 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
7951 return;
7952 }
7953
7954
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 113343 times.
113653 bool stretched = (sw != dw || sh != dh);
7955
7956 113653 BITMAP* newDest = sourceBitmap;
7957 113653 BITMAP* newSource = destBMP; //Flip them.
7958
7959 113653 BITMAP* subBmp = 0;
7960
7961
2/4
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 113653 times.
113653 if(rot != 0 || mode != 0)
7962 {
7963 subBmp = create_bitmap_ex(8,sourceBitmap->w, sourceBitmap->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
7964 clear_bitmap(subBmp);
7965
7966 if(!subBmp)
7967 {
7968 Z_scripterrlog("bitmap->Blit failed to create a sub-bitmap to use for %s. Aborting.\n", "rotation");
7969 return;
7970 }
7971 }
7972
7973
3/4
✓ Branch 0 taken 113653 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 113650 times.
113653 if (sx + sw > destBMP->w || sy + sh > destBMP->h)
7974 {
7975 3 newSource = create_bitmap_ex(8, sw, sh);
7976 3 clear_bitmap(newSource);
7977 3 blit(destBMP, newSource, sx, sy, 0, 0, std::min(destBMP->w-sx, sw), std::min(destBMP->h-sy, sh));
7978 3 sx = 0;
7979 3 sy = 0;
7980 3 }
7981 //dx = dx + xoffset; //don't do this here!
7982 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
7983
7984
2/2
✓ Branch 0 taken 310 times.
✓ Branch 1 taken 113343 times.
113653 if(stretched)
7985 {
7986
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if(masked)
7987 { //stretched and masked
7988 if ( rot == 0 )
7989 { //if not rotated
7990 switch(mode)
7991 {
7992 case 1:
7993 //transparent
7994 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
7995 draw_trans_sprite(newDest, subBmp, dx, dy);
7996 break;
7997
7998
7999 case 2:
8000 //pivot?
8001 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8002 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8003 //Pivoting requires two more args
8004 break;
8005
8006 case 3:
8007 //pivot + trans
8008 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8009 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8010 break;
8011
8012 case 4:
8013 //flip v
8014 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8015 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8016 break;
8017
8018 case 5:
8019 //trans + v flip
8020 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8021 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8022 break;
8023
8024 case 6:
8025 //pivot + v flip
8026 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8027 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8028 break;
8029
8030 case 8:
8031 //vlip h
8032 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8033 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8034 break;
8035
8036 case 9:
8037 //trans + h flip
8038 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8039 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8040 break;
8041
8042 case 10:
8043 //flip H and pivot
8044 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8045 //return error cannot pivot and h flip
8046 break;
8047
8048 case 12:
8049 //vh flip
8050 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8051 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8052 break;
8053
8054 case 13:
8055 //trans + vh flip
8056 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8057 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8058 break;
8059
8060 case 14:
8061 //pivot and vh flip
8062 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8063 //return error cannot both pivot and vh flip
8064 break;
8065
8066 case 16:
8067 //lit
8068 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8069 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8070 break;
8071
8072 case 18:
8073 //pivot, lit
8074 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8075 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8076 break;
8077
8078 case 20:
8079 //lit + v flip
8080 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8081 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8082 break;
8083
8084 case 22:
8085 //Pivot, vflip, lit
8086 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8087 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8088 break;
8089
8090 case 24:
8091 //lit + h flip
8092 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8093 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8094 break;
8095
8096 case 26:
8097 //pivot + lit + hflip
8098 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8099 //return error cannot pivot, lit, and flip
8100 break;
8101
8102 case 28:
8103 //lit + vh flip
8104 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8105 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8106 break;
8107
8108 case 32: //gouraud
8109 //Probably not wort supporting.
8110 //masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8111 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8112 break;
8113
8114 case 0:
8115 //no effect
8116 masked_stretch_blit(newSource, newDest, sx, sy, sw, sh, dx, dy, dw, dh);
8117 break;
8118
8119
8120 default:
8121 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8122
8123
8124 }
8125 } //end if not rotated
8126
8127 if ( rot != 0 ) //if rotated
8128 {
8129 switch(mode)
8130 {
8131 case 1:
8132 //transparent
8133 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8134 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8135
8136 break;
8137
8138 case 2:
8139 //pivot?
8140 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8141 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8142 //Pivoting requires two more args
8143 break;
8144
8145 case 3:
8146 //pivot + trans
8147 //return an error, cannot both rotate and pivot
8148 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8149 break;
8150
8151 case 4:
8152 //flip v
8153 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8154 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8155 break;
8156
8157 case 5:
8158 //trans + v flip
8159 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8160 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8161 break;
8162
8163 case 6:
8164 //pivot + v flip
8165 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8166 //return an error, cannot both rotate and pivot
8167 break;
8168
8169 case 8:
8170 //flip h
8171 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8172 //return an error, cannot both rotate and flip H
8173 break;
8174
8175 case 9:
8176 //trans + h flip
8177 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8178 //return an error, cannot rotate and flip a trans sprite
8179 break;
8180
8181 case 10:
8182 //flip H and pivot
8183 //return error cannot pivot and h flip
8184 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8185 break;
8186
8187 case 12:
8188 //vh flip
8189 //return an error, cannot rotate and VH flip a trans sprite
8190 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8191 break;
8192
8193 case 13:
8194 //trans + vh flip
8195 //return an error, cannot rotate and VH flip a trans sprite
8196 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8197 break;
8198
8199 case 14:
8200 //pivot and vh flip
8201 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8202 //return error cannot both pivot and vh flip
8203 break;
8204
8205 case 16:
8206 //lit
8207 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8208 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8209 break;
8210
8211 case 18:
8212 //pivot, lit
8213 //return an error, cannot both rotate and pivot
8214 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8215 break;
8216
8217 case 20:
8218 //lit + vflip
8219 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8220 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8221 break;
8222
8223 case 22:
8224 //Pivot, vflip, lit
8225 //return an error, cannot both rotate and pivot
8226 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8227 break;
8228
8229 case 24:
8230 //lit + h flip
8231 //return an error, cannot both rotate and H flip
8232 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8233 break;
8234
8235 case 26:
8236 //pivot + lit + hflip
8237 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8238 //return error cannot pivot, lit, and flip
8239 break;
8240
8241 case 28:
8242 //lit + vh flip
8243 //return an error, cannot both rotate and VH flip
8244 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8245 break;
8246
8247 case 32: //gouraud
8248 //Probably not wort supporting.
8249 //masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8250 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8251 break;
8252
8253 case 0:
8254 //no effect.
8255 masked_stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8256 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8257 break;
8258
8259 default:
8260 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8261
8262 }
8263 }
8264 } //end if stretched and masked
8265
8266 else //stretched, not masked
8267 {
8268
8269
8270
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 310 times.
310 if ( rot == 0 ) //if not rotated
8271 {
8272
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 310 times.
310 switch(mode)
8273 {
8274 case 1:
8275 //transparent
8276 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8277 draw_trans_sprite(newDest, subBmp, dx, dy);
8278 break;
8279
8280
8281 case 2:
8282 //pivot?
8283 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8284 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8285 //Pivoting requires two more args
8286 break;
8287
8288 case 3:
8289 //pivot + trans
8290 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8291 pivot_sprite_trans(newDest, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
8292 break;
8293
8294 case 4:
8295 //flip v
8296 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8297 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8298 break;
8299
8300 case 5:
8301 //trans + v flip
8302 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8303 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8304 break;
8305
8306 case 6:
8307 //pivot + v flip
8308 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8309 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8310 break;
8311
8312 case 8:
8313 //vlip h
8314 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8315 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8316 break;
8317
8318 case 9:
8319 //trans + h flip
8320 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8321 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8322 break;
8323
8324 case 10:
8325 //flip H and pivot
8326 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8327 //return error cannot pivot and h flip
8328 break;
8329
8330 case 12:
8331 //vh flip
8332 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8333 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8334 break;
8335
8336 case 13:
8337 //trans + vh flip
8338 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8339 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8340 break;
8341
8342 case 14:
8343 //pivot and vh flip
8344 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8345 //return error cannot both pivot and vh flip
8346 break;
8347
8348 case 16:
8349 //lit
8350 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8351 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8352 break;
8353
8354 case 18:
8355 //pivot, lit
8356 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8357 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8358 break;
8359
8360 case 20:
8361 //lit + v flip
8362 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8363 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8364 break;
8365
8366 case 22:
8367 //Pivot, vflip, lit
8368 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8369 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8370 break;
8371
8372 case 24:
8373 //lit + h flip
8374 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8375 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8376 break;
8377
8378 case 26:
8379 //pivot + lit + hflip
8380 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8381 //return error cannot pivot, lit, and flip
8382 break;
8383
8384 case 28:
8385 //lit + vh flip
8386 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8387 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8388 break;
8389
8390 case 32: //gouraud
8391 //Probably not wort supporting.
8392 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8393 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8394 break;
8395
8396 case 0:
8397 //no effect
8398 310 stretch_blit(newSource, newDest, sx, sy, sw, sh, dx, dy, dw, dh);
8399 310 break;
8400
8401
8402 default:
8403 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8404
8405
8406 }
8407 310 } //end if not rotated
8408
8409
1/2
✓ Branch 0 taken 310 times.
✗ Branch 1 not taken.
310 if ( rot != 0 ) //if rotated
8410 {
8411 switch(mode)
8412 {
8413 case 1:
8414 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8415 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8416
8417 break;
8418
8419 case 2:
8420 //pivot?
8421 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8422 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8423 //Pivoting requires two more args
8424 break;
8425
8426 case 3:
8427 //pivot + trans
8428 //return an error, cannot both rotate and pivot
8429 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8430 break;
8431
8432 case 4:
8433 //flip v
8434 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8435 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8436 break;
8437
8438 case 5:
8439 //trans + v flip
8440 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8441 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8442 break;
8443
8444 case 6:
8445 //pivot + v flip
8446 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8447 //return an error, cannot both rotate and pivot
8448 break;
8449
8450 case 8:
8451 //flip h
8452 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8453 //return an error, cannot both rotate and flip H
8454 break;
8455
8456 case 9:
8457 //trans + h flip
8458 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8459 //return an error, cannot rotate and flip a trans sprite
8460 break;
8461
8462 case 10:
8463 //flip H and pivot
8464 //return error cannot pivot and h flip
8465 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8466 break;
8467
8468 case 12:
8469 //vh flip
8470 //return an error, cannot rotate and VH flip a trans sprite
8471 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8472 break;
8473
8474 case 13:
8475 //trans + vh flip
8476 //return an error, cannot rotate and VH flip a trans sprite
8477 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8478 break;
8479
8480 case 14:
8481 //pivot and vh flip
8482 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8483 //return error cannot both pivot and vh flip
8484 break;
8485
8486 case 16:
8487 //lit
8488 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8489 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8490 break;
8491
8492 case 18:
8493 //pivot, lit
8494 //return an error, cannot both rotate and pivot
8495 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8496 break;
8497
8498 case 20:
8499 //lit + vflip
8500 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
8501 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8502 break;
8503
8504 case 22:
8505 //Pivot, vflip, lit
8506 //return an error, cannot both rotate and pivot
8507 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8508 break;
8509
8510 case 24:
8511 //lit + h flip
8512 //return an error, cannot both rotate and H flip
8513 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8514 break;
8515
8516 case 26:
8517 //pivot + lit + hflip
8518 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8519 //return error cannot pivot, lit, and flip
8520 break;
8521
8522 case 28:
8523 //lit + vh flip
8524 //return an error, cannot both rotate and VH flip
8525 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8526 break;
8527
8528 case 32: //gouraud
8529 //Probably not wort supporting.
8530 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8531 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8532 break;
8533
8534 case 0:
8535 //no effect.
8536 stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8537 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8538 break;
8539
8540 default:
8541 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8542
8543 }
8544 }
8545
8546 } //end if stretched, but not masked
8547 310 }
8548 else //not stretched
8549 {
8550
8551
2/2
✓ Branch 0 taken 113326 times.
✓ Branch 1 taken 17 times.
113343 if(masked) //if masked, but not stretched
8552 {
8553
8554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113326 times.
113326 if ( rot == 0 ) //if not rotated
8555 {
8556
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 113326 times.
113326 switch(mode)
8557 {
8558 case 1:
8559 //transparent
8560 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8561 draw_trans_sprite(newDest, subBmp, dx, dy);
8562 break;
8563
8564
8565 case 2:
8566 //pivot?
8567 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8568 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8569 //Pivoting requires two more args
8570 break;
8571
8572 case 3:
8573 //pivot + trans
8574 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8575 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8576 break;
8577
8578 case 4:
8579 //flip v
8580 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8581 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8582 break;
8583
8584 case 5:
8585 //trans + v flip
8586 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8587 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8588 break;
8589
8590 case 6:
8591 //pivot + v flip
8592 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8593 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8594 break;
8595
8596 case 8:
8597 //vlip h
8598 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8599 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8600 break;
8601
8602 case 9:
8603 //trans + h flip
8604 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8605 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8606 break;
8607
8608 case 10:
8609 //flip H and pivot
8610 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8611 //return error cannot pivot and h flip
8612 break;
8613
8614 case 12:
8615 //vh flip
8616 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8617 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8618 break;
8619
8620 case 13:
8621 //trans + vh flip
8622 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8623 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8624 break;
8625
8626 case 14:
8627 //pivot and vh flip
8628 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8629 //return error cannot both pivot and vh flip
8630 break;
8631
8632 case 16:
8633 //lit
8634 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8635 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8636 break;
8637
8638 case 18:
8639 //pivot, lit
8640 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8641 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8642 break;
8643
8644 case 20:
8645 //lit + v flip
8646 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8647 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8648 break;
8649
8650 case 22:
8651 //Pivot, vflip, lit
8652 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8653 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8654 break;
8655
8656 case 24:
8657 //lit + h flip
8658 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8659 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8660 break;
8661
8662 case 26:
8663 //pivot + lit + hflip
8664 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8665 //return error cannot pivot, lit, and flip
8666 break;
8667
8668 case 28:
8669 //lit + vh flip
8670 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8671 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8672 break;
8673
8674 case 32: //gouraud
8675 //Probably not wort supporting.
8676 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8677 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8678 break;
8679
8680 case 0:
8681 //no effect
8682 113326 masked_blit(newSource, newDest, sx, sy, dx, dy, dw, dh);
8683 113326 break;
8684
8685
8686 default:
8687 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8688
8689
8690 }
8691 113326 } //end if not rotated
8692
8693
1/2
✓ Branch 0 taken 113326 times.
✗ Branch 1 not taken.
113326 if ( rot != 0 ) //if rotated
8694 {
8695 switch(mode)
8696 {
8697 case 1:
8698 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); //transparent
8699 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8700
8701 break;
8702
8703 case 2:
8704 //pivot?
8705 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8706 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8707 //Pivoting requires two more args
8708 break;
8709
8710 case 3:
8711 //pivot + trans
8712 //return an error, cannot both rotate and pivot
8713 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8714 break;
8715
8716 case 4:
8717 //flip v
8718 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8719 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8720 break;
8721
8722 case 5:
8723 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
8724 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8725 break;
8726
8727 case 6:
8728 //pivot + v flip
8729 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8730 //return an error, cannot both rotate and pivot
8731 break;
8732
8733 case 8:
8734 //flip h
8735 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
8736 //return an error, cannot both rotate and flip H
8737 break;
8738
8739 case 9:
8740 //trans + h flip
8741 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
8742 //return an error, cannot rotate and flip a trans sprite
8743 break;
8744
8745 case 10:
8746 //flip H and pivot
8747 //return error cannot pivot and h flip
8748 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8749 break;
8750
8751 case 12:
8752 //vh flip
8753 //return an error, cannot rotate and VH flip a trans sprite
8754 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8755 break;
8756
8757 case 13:
8758 //trans + vh flip
8759 //return an error, cannot rotate and VH flip a trans sprite
8760 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
8761 break;
8762
8763 case 14:
8764 //pivot and vh flip
8765 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8766 //return error cannot both pivot and vh flip
8767 break;
8768
8769 case 16:
8770 //lit
8771 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8772 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8773 break;
8774
8775 case 18:
8776 //pivot, lit
8777 //return an error, cannot both rotate and pivot
8778 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8779 break;
8780
8781 case 20:
8782 //lit + vflip
8783 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8784 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
8785 break;
8786
8787 case 22:
8788 //Pivot, vflip, lit
8789 //return an error, cannot both rotate and pivot
8790 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
8791 break;
8792
8793 case 24:
8794 //lit + h flip
8795 //return an error, cannot both rotate and H flip
8796 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
8797 break;
8798
8799 case 26:
8800 //pivot + lit + hflip
8801 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
8802 //return error cannot pivot, lit, and flip
8803 break;
8804
8805 case 28:
8806 //lit + vh flip
8807 //return an error, cannot both rotate and VH flip
8808 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8809 break;
8810
8811 case 32: //gouraud
8812 //Probably not wort supporting.
8813 //stretch_blit(newSource, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
8814 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8815 break;
8816
8817 case 0:
8818 //no effect.
8819 masked_blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8820 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8821 break;
8822
8823 default:
8824 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8825
8826 }
8827 } //end rtated, masked
8828 113326 } //end if masked
8829
8830 else //not masked, and not stretched; just blit
8831 {
8832
8833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17 times.
17 if ( rot == 0 ) //if not rotated
8834 {
8835
1/22
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✗ Branch 14 not taken.
✗ Branch 15 not taken.
✗ Branch 16 not taken.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✗ Branch 19 not taken.
✗ Branch 20 not taken.
✓ Branch 21 taken 17 times.
17 switch(mode)
8836 {
8837 case 1:
8838 //transparent
8839 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8840 draw_trans_sprite(newDest, subBmp, dx, dy);
8841 break;
8842
8843
8844 case 2:
8845 //pivot?
8846 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8847 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8848 //Pivoting requires two more args
8849 break;
8850
8851 case 3:
8852 //pivot + trans
8853 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8854 pivot_sprite_trans(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8855 break;
8856
8857 case 4:
8858 //flip v
8859 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8860 draw_sprite_v_flip(newDest, subBmp, dx, dy);
8861 break;
8862
8863 case 5:
8864 //trans + v flip
8865 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8866 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
8867 break;
8868
8869 case 6:
8870 //pivot + v flip
8871 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8872 pivot_sprite_v_flip(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8873 break;
8874
8875 case 8:
8876 //vlip h
8877 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8878 draw_sprite_h_flip(newDest, subBmp, dx, dy);
8879 break;
8880
8881 case 9:
8882 //trans + h flip
8883 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8884 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
8885 break;
8886
8887 case 10:
8888 //flip H and pivot
8889 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
8890 //return error cannot pivot and h flip
8891 break;
8892
8893 case 12:
8894 //vh flip
8895 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8896 draw_sprite_vh_flip(newDest, subBmp, dx, dy);
8897 break;
8898
8899 case 13:
8900 //trans + vh flip
8901 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8902 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
8903 break;
8904
8905 case 14:
8906 //pivot and vh flip
8907 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
8908 //return error cannot both pivot and vh flip
8909 break;
8910
8911 case 16:
8912 //lit
8913 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8914 draw_lit_sprite(newDest, subBmp, dx, dy, litcolour);
8915 break;
8916
8917 case 18:
8918 //pivot, lit
8919 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8920 pivot_sprite_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8921 break;
8922
8923 case 20:
8924 //lit + v flip
8925 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8926 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
8927 break;
8928
8929 case 22:
8930 //Pivot, vflip, lit
8931 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8932 pivot_sprite_v_flip_lit(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
8933 break;
8934
8935 case 24:
8936 //lit + h flip
8937 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8938 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
8939 break;
8940
8941 case 26:
8942 //pivot + lit + hflip
8943 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot, Flip, and Lit.\n", bitmapIndex);
8944 //return error cannot pivot, lit, and flip
8945 break;
8946
8947 case 28:
8948 //lit + vh flip
8949 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8950 draw_sprite_ex(newDest, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
8951 break;
8952
8953 case 32: //gouraud
8954 //Probably not wort supporting.
8955 //blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8956 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
8957 break;
8958
8959 case 0:
8960 //no effect
8961 17 blit(newSource, newDest, sx, sy, dx, dy, dw, dh);
8962 17 break;
8963
8964
8965 default:
8966 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
8967
8968
8969 }
8970 17 } //end if not rotated
8971
8972
1/2
✓ Branch 0 taken 17 times.
✗ Branch 1 not taken.
17 if ( rot != 0 ) //if rotated
8973 {
8974 switch(mode)
8975 {
8976 case 1:
8977 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);//transparent
8978 rotate_sprite_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8979
8980 break;
8981
8982 case 2:
8983 //pivot?
8984 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8985 pivot_sprite(newDest, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
8986 //Pivoting requires two more args
8987 break;
8988
8989 case 3:
8990 //pivot + trans
8991 //return an error, cannot both rotate and pivot
8992 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
8993 break;
8994
8995 case 4:
8996 //flip v
8997 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
8998 rotate_sprite_v_flip(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
8999 break;
9000
9001 case 5:
9002 //trans + v flip
9003 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9004 rotate_sprite_v_flip_trans(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9005 break;
9006
9007 case 6:
9008 //pivot + v flip
9009 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9010 //return an error, cannot both rotate and pivot
9011 break;
9012
9013 case 8:
9014 //flip h
9015 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rorate and H-Flip.\n", bitmapIndex);
9016 //return an error, cannot both rotate and flip H
9017 break;
9018
9019 case 9:
9020 //trans + h flip
9021 Z_message("Warning: Screen->DrawBitmap(%d) cannot Rotate and Flip a Trans Sprite.\n", bitmapIndex);
9022 //return an error, cannot rotate and flip a trans sprite
9023 break;
9024
9025 case 10:
9026 //flip H and pivot
9027 //return error cannot pivot and h flip
9028 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and H-Flip.\n", bitmapIndex);
9029 break;
9030
9031 case 12:
9032 //vh flip
9033 //return an error, cannot rotate and VH flip a trans sprite
9034 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
9035 break;
9036
9037 case 13:
9038 //trans + vh flip
9039 //return an error, cannot rotate and VH flip a trans sprite
9040 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and VH-Flip.\n", bitmapIndex);
9041 break;
9042
9043 case 14:
9044 //pivot and vh flip
9045 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
9046 //return error cannot both pivot and vh flip
9047 break;
9048
9049 case 16:
9050 //lit
9051 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9052 rotate_sprite_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9053 break;
9054
9055 case 18:
9056 //pivot, lit
9057 //return an error, cannot both rotate and pivot
9058 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rorate.\n", bitmapIndex);
9059 break;
9060
9061 case 20:
9062 //lit + vflip
9063 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9064 rotate_sprite_v_flip_lit(newDest, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9065 break;
9066
9067 case 22:
9068 //Pivot, vflip, lit
9069 //return an error, cannot both rotate and pivot
9070 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Rotate.\n", bitmapIndex);
9071 break;
9072
9073 case 24:
9074 //lit + h flip
9075 //return an error, cannot both rotate and H flip
9076 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Rotate and H-Flip.\n", bitmapIndex);
9077 break;
9078
9079 case 26:
9080 //pivot + lit + hflip
9081 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and Flip a Lit Sprite.\n", bitmapIndex);
9082 //return error cannot pivot, lit, and flip
9083 break;
9084
9085 case 28:
9086 //lit + vh flip
9087 //return an error, cannot both rotate and VH flip
9088 Z_message("Warning: Screen->DrawBitmap(%d) cannot both Pivot and VH-Flip.\n", bitmapIndex);
9089 break;
9090
9091 case 32: //gouraud
9092 //Probably not wort supporting.
9093 //blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9094 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9095 break;
9096
9097 case 0:
9098 //no effect.
9099 blit(newSource, subBmp, sx, sy, 0, 0, dw, dh);
9100 rotate_sprite(newDest, subBmp, dx, dy, degrees_to_fixed(rot));
9101 break;
9102
9103 default:
9104 return Z_message("Warning: Screen->DrawBitmap(%d) mode flags not possible in this combination!\n", bitmapIndex);
9105
9106 }
9107 } //end if rotated
9108 } //end if not masked
9109 } //end if not stretched
9110
9111 //cleanup
9112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 113653 times.
113653 if(subBmp)
9113 {
9114 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
9115 destroy_bitmap(subBmp);
9116 }
9117
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 113650 times.
113653 if(newSource != destBMP)
9118 {
9119 3 destroy_bitmap(newSource);
9120 3 }
9121 113653 }
9122
9123 void do_tileblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool is_bmp, char const* funcstr)
9124 {
9125 /*
9126 //sdci[1]=layer
9127 //sdci[2]=tile
9128 //sdci[3]=cset
9129 //sdci[4]=sourcex
9130 //sdci[5]=sourcey
9131 //sdci[6]=sourcew
9132 //sdci[7]=sourceh
9133 //sdci[8]=destx
9134 //sdci[9]=desty
9135 //sdci[10]=destw
9136 //sdci[11]=desth
9137 //sdci[12]=rotation/angle
9138 //scdi[13] = pivot cx
9139 //sdci[14] = pivot cy
9140 //scdi[15] = effect flags
9141
9142 // ZScript-side constant values:
9143 const int32_t BITDX_NORMAL = 0;
9144 const int32_t BITDX_TRANS = 1; //Translucent
9145 const int32_t BITDX_PIVOT = 2; //THe sprite will rotate at a specific point, instead of its center.
9146 const int32_t BITDX_HFLIP = 4; //Horizontal Flip
9147 const int32_t BITDX_VFLIP = 8; //Vertical Flip.
9148 //Note: Some modes cannot be combined. if a combination is not supported, an error
9149 // detailing this will be shown in allegro.log.
9150
9151 //scdi[16] = litcolour
9152 //The allegro docs are wrong. The params are: rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9153 //not rotate_sprite_lit(bmp, subBmp, dx, dy, degrees_to_fixed(rot));
9154
9155 //sdci[17]=mask
9156 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
9157
9158 */
9159
9160 int32_t tile = sdci[2]/10000;
9161 int32_t cset = WRAP_CS(sdci[3]/10000);
9162
9163 int32_t sx = sdci[4]/10000;
9164 int32_t sy = sdci[5]/10000;
9165 int32_t sw = sdci[6]/10000;
9166 //Z_scripterrlog("sh is: %d\n",sdci[5]/10000);
9167 int32_t sh = sdci[7]/10000;
9168 //Z_scripterrlog("sh is: %d\n",sdci[6]/10000);
9169 int32_t dx = sdci[8]/10000;
9170 int32_t dy = sdci[9]/10000;
9171 int32_t dw = sdci[10]/10000;
9172 int32_t dh = sdci[11]/10000;
9173 float rot = sdci[12]/10000;
9174 int32_t cx = sdci[13]/10000;
9175 int32_t cy = sdci[14]/10000;
9176 int32_t mode = sdci[15]/10000;
9177 int32_t litcolour = sdci[16]/10000;
9178 bool masked = (sdci[17] != 0);
9179
9180 int32_t ref = 0;
9181
9182 if ( is_bmp && (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
9183 //Do we need to also check the render target and do the same thing if the
9184 //dest == -2 and the render target is not RT_SCREEN?
9185 dx += xoffset;
9186 dy += yoffset;
9187
9188 BITMAP *destbmp = nullptr;
9189 if(is_bmp)
9190 {
9191 ref = sdci[DRAWCMD_BMP_TARGET];
9192
9193 if ( ref <= 0 )
9194 {
9195 Z_scripterrlog("%s wanted to use to an invalid dest bitmap id: %d. Aborting.\n", funcstr, ref);
9196 return;
9197 }
9198 destbmp = resolveScriptingBitmap(ref);
9199 if(!destbmp)
9200 {
9201 Z_message("Warning: %s dest bitmap %d contains invalid data or is not initialized.\n", ref);
9202 Z_message("[Note* Deferred drawing or layering order possibly not set right.]\n");
9203 return;
9204 }
9205 }
9206 else destbmp = bmp;
9207
9208 bool stretched = (sw != dw || sh != dh);
9209
9210 BITMAP* srcbmp = create_bitmap_ex(8, sw, sh);
9211 //Draw tiles to srcbmp
9212 {
9213 clear_bitmap(srcbmp);
9214 int tx = 0, ty = 0;
9215 if(sx < 0)
9216 tx = (sx-15)/16;
9217 else if(sx > 15)
9218 tx = sx/16;
9219 if(sy < 0)
9220 ty = (sy-15)/16;
9221 else if(sy > 15)
9222 ty = sy/16;
9223
9224 int gxoff = -wrap(sx,0,15), gyoff = -wrap(sy,0,15);
9225 for(int ix = 0; ix <= sw; ix += 16)
9226 {
9227 for(int iy = 0; iy <= sh; iy += 16)
9228 {
9229 int t = tile+(tx+ix/16);
9230 int rowdiff = TILEROW(t) - TILEROW(tile);
9231 t += rowdiff * (sh/16) * TILES_PER_ROW;
9232 t += (ty+iy/16)*TILES_PER_ROW;
9233 overtile16(srcbmp, t, ix+gxoff, iy+gyoff, cset, 0);
9234 }
9235 }
9236
9237 sx = sy = 0;
9238 }
9239
9240 BITMAP* subBmp = nullptr;
9241
9242 if(rot != 0 || mode != 0)
9243 {
9244 subBmp = create_bitmap_ex(8,destbmp->w, destbmp->h);//script_drawing_commands.AquireSubBitmap(dw, dh);
9245 clear_bitmap(subBmp);
9246
9247 if(!subBmp)
9248 {
9249 Z_scripterrlog("%s failed to create a sub-bitmap to use for %s. Aborting.\n", funcstr, "rotation");
9250 return;
9251 }
9252 }
9253
9254 //dx = dx + xoffset; //don't do this here!
9255 //dy = dy + yoffset; //Nor this. It auto-offsets the bitmap by +56. Hmm. The fix that gleeok made isn't being applied to these functions. -Z ( 17th April, 2019 )
9256
9257 if(stretched)
9258 {
9259 if(masked)
9260 { //stretched and masked
9261 if ( rot == 0 )
9262 { //if not rotated
9263 switch(mode)
9264 {
9265 case 1:
9266 //transparent
9267 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9268 draw_trans_sprite(destbmp, subBmp, dx, dy);
9269 break;
9270
9271
9272 case 2:
9273 //pivot?
9274 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9275 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9276 //Pivoting requires two more args
9277 break;
9278
9279 case 3:
9280 //pivot + trans
9281 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9282 pivot_sprite_trans(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9283 break;
9284
9285 case 4:
9286 //flip v
9287 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9288 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
9289 break;
9290
9291 case 5:
9292 //trans + v flip
9293 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9294 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
9295 break;
9296
9297 case 6:
9298 //pivot + v flip
9299 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9300 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9301 break;
9302
9303 case 8:
9304 //vlip h
9305 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9306 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
9307 break;
9308
9309 case 9:
9310 //trans + h flip
9311 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9312 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
9313 break;
9314
9315 case 10:
9316 //flip H and pivot
9317 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9318 //return error cannot pivot and h flip
9319 break;
9320
9321 case 12:
9322 //vh flip
9323 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9324 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
9325 break;
9326
9327 case 13:
9328 //trans + vh flip
9329 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9330 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
9331 break;
9332
9333 case 14:
9334 //pivot and vh flip
9335 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9336 //return error cannot both pivot and vh flip
9337 break;
9338
9339 case 16:
9340 //lit
9341 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9342 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
9343 break;
9344
9345 case 18:
9346 //pivot, lit
9347 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9348 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9349 break;
9350
9351 case 20:
9352 //lit + v flip
9353 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9354 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
9355 break;
9356
9357 case 22:
9358 //Pivot, vflip, lit
9359 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9360 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9361 break;
9362
9363 case 24:
9364 //lit + h flip
9365 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9366 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
9367 break;
9368
9369 case 26:
9370 //pivot + lit + hflip
9371 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
9372 //return error cannot pivot, lit, and flip
9373 break;
9374
9375 case 28:
9376 //lit + vh flip
9377 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9378 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
9379 break;
9380
9381 case 32: //gouraud
9382 //Probably not wort supporting.
9383 //masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9384 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9385 break;
9386
9387 case 0:
9388 //no effect
9389 masked_stretch_blit(srcbmp, destbmp, sx, sy, sw, sh, dx, dy, dw, dh);
9390 break;
9391
9392
9393 default:
9394 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9395
9396
9397 }
9398 } //end if not rotated
9399
9400 if ( rot != 0 ) //if rotated
9401 {
9402 switch(mode)
9403 {
9404 case 1:
9405 //transparent
9406 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9407 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9408
9409 break;
9410
9411 case 2:
9412 //pivot?
9413 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9414 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9415 //Pivoting requires two more args
9416 break;
9417
9418 case 3:
9419 //pivot + trans
9420 //return an error, cannot both rotate and pivot
9421 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9422 break;
9423
9424 case 4:
9425 //flip v
9426 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9427 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9428 break;
9429
9430 case 5:
9431 //trans + v flip
9432 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9433 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9434 break;
9435
9436 case 6:
9437 //pivot + v flip
9438 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9439 //return an error, cannot both rotate and pivot
9440 break;
9441
9442 case 8:
9443 //flip h
9444 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9445 //return an error, cannot both rotate and flip H
9446 break;
9447
9448 case 9:
9449 //trans + h flip
9450 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
9451 //return an error, cannot rotate and flip a trans sprite
9452 break;
9453
9454 case 10:
9455 //flip H and pivot
9456 //return error cannot pivot and h flip
9457 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9458 break;
9459
9460 case 12:
9461 //vh flip
9462 //return an error, cannot rotate and VH flip a trans sprite
9463 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9464 break;
9465
9466 case 13:
9467 //trans + vh flip
9468 //return an error, cannot rotate and VH flip a trans sprite
9469 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9470 break;
9471
9472 case 14:
9473 //pivot and vh flip
9474 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9475 //return error cannot both pivot and vh flip
9476 break;
9477
9478 case 16:
9479 //lit
9480 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9481 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9482 break;
9483
9484 case 18:
9485 //pivot, lit
9486 //return an error, cannot both rotate and pivot
9487 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9488 break;
9489
9490 case 20:
9491 //lit + vflip
9492 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9493 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9494 break;
9495
9496 case 22:
9497 //Pivot, vflip, lit
9498 //return an error, cannot both rotate and pivot
9499 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9500 break;
9501
9502 case 24:
9503 //lit + h flip
9504 //return an error, cannot both rotate and H flip
9505 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9506 break;
9507
9508 case 26:
9509 //pivot + lit + hflip
9510 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
9511 //return error cannot pivot, lit, and flip
9512 break;
9513
9514 case 28:
9515 //lit + vh flip
9516 //return an error, cannot both rotate and VH flip
9517 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9518 break;
9519
9520 case 32: //gouraud
9521 //Probably not wort supporting.
9522 //masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9523 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9524 break;
9525
9526 case 0:
9527 //no effect.
9528 masked_stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9529 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9530 break;
9531
9532 default:
9533 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9534
9535 }
9536 }
9537 } //end if stretched and masked
9538
9539 else //stretched, not masked
9540 {
9541
9542
9543 if ( rot == 0 ) //if not rotated
9544 {
9545 switch(mode)
9546 {
9547 case 1:
9548 //transparent
9549 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9550 draw_trans_sprite(destbmp, subBmp, dx, dy);
9551 break;
9552
9553
9554 case 2:
9555 //pivot?
9556 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9557 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9558 //Pivoting requires two more args
9559 break;
9560
9561 case 3:
9562 //pivot + trans
9563 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9564 pivot_sprite_trans(destbmp, subBmp, dx,dy, cx, cy, degrees_to_fixed(rot));
9565 break;
9566
9567 case 4:
9568 //flip v
9569 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9570 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
9571 break;
9572
9573 case 5:
9574 //trans + v flip
9575 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9576 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
9577 break;
9578
9579 case 6:
9580 //pivot + v flip
9581 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9582 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9583 break;
9584
9585 case 8:
9586 //vlip h
9587 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9588 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
9589 break;
9590
9591 case 9:
9592 //trans + h flip
9593 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9594 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
9595 break;
9596
9597 case 10:
9598 //flip H and pivot
9599 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9600 //return error cannot pivot and h flip
9601 break;
9602
9603 case 12:
9604 //vh flip
9605 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9606 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
9607 break;
9608
9609 case 13:
9610 //trans + vh flip
9611 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9612 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
9613 break;
9614
9615 case 14:
9616 //pivot and vh flip
9617 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9618 //return error cannot both pivot and vh flip
9619 break;
9620
9621 case 16:
9622 //lit
9623 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9624 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
9625 break;
9626
9627 case 18:
9628 //pivot, lit
9629 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9630 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9631 break;
9632
9633 case 20:
9634 //lit + v flip
9635 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9636 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
9637 break;
9638
9639 case 22:
9640 //Pivot, vflip, lit
9641 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9642 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9643 break;
9644
9645 case 24:
9646 //lit + h flip
9647 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9648 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
9649 break;
9650
9651 case 26:
9652 //pivot + lit + hflip
9653 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
9654 //return error cannot pivot, lit, and flip
9655 break;
9656
9657 case 28:
9658 //lit + vh flip
9659 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9660 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
9661 break;
9662
9663 case 32: //gouraud
9664 //Probably not wort supporting.
9665 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9666 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9667 break;
9668
9669 case 0:
9670 //no effect
9671 stretch_blit(srcbmp, destbmp, sx, sy, sw, sh, dx, dy, dw, dh);
9672 break;
9673
9674
9675 default:
9676 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9677
9678
9679 }
9680 } //end if not rotated
9681
9682 if ( rot != 0 ) //if rotated
9683 {
9684 switch(mode)
9685 {
9686 case 1:
9687 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
9688 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9689
9690 break;
9691
9692 case 2:
9693 //pivot?
9694 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9695 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9696 //Pivoting requires two more args
9697 break;
9698
9699 case 3:
9700 //pivot + trans
9701 //return an error, cannot both rotate and pivot
9702 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9703 break;
9704
9705 case 4:
9706 //flip v
9707 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9708 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9709 break;
9710
9711 case 5:
9712 //trans + v flip
9713 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9714 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9715 break;
9716
9717 case 6:
9718 //pivot + v flip
9719 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9720 //return an error, cannot both rotate and pivot
9721 break;
9722
9723 case 8:
9724 //flip h
9725 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9726 //return an error, cannot both rotate and flip H
9727 break;
9728
9729 case 9:
9730 //trans + h flip
9731 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
9732 //return an error, cannot rotate and flip a trans sprite
9733 break;
9734
9735 case 10:
9736 //flip H and pivot
9737 //return error cannot pivot and h flip
9738 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9739 break;
9740
9741 case 12:
9742 //vh flip
9743 //return an error, cannot rotate and VH flip a trans sprite
9744 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9745 break;
9746
9747 case 13:
9748 //trans + vh flip
9749 //return an error, cannot rotate and VH flip a trans sprite
9750 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
9751 break;
9752
9753 case 14:
9754 //pivot and vh flip
9755 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9756 //return error cannot both pivot and vh flip
9757 break;
9758
9759 case 16:
9760 //lit
9761 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
9762 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9763 break;
9764
9765 case 18:
9766 //pivot, lit
9767 //return an error, cannot both rotate and pivot
9768 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9769 break;
9770
9771 case 20:
9772 //lit + vflip
9773 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);//transparent
9774 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
9775 break;
9776
9777 case 22:
9778 //Pivot, vflip, lit
9779 //return an error, cannot both rotate and pivot
9780 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9781 break;
9782
9783 case 24:
9784 //lit + h flip
9785 //return an error, cannot both rotate and H flip
9786 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
9787 break;
9788
9789 case 26:
9790 //pivot + lit + hflip
9791 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
9792 //return error cannot pivot, lit, and flip
9793 break;
9794
9795 case 28:
9796 //lit + vh flip
9797 //return an error, cannot both rotate and VH flip
9798 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9799 break;
9800
9801 case 32: //gouraud
9802 //Probably not wort supporting.
9803 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9804 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9805 break;
9806
9807 case 0:
9808 //no effect.
9809 stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9810 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9811 break;
9812
9813 default:
9814 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9815
9816 }
9817 }
9818
9819 } //end if stretched, but not masked
9820 }
9821 else //not stretched
9822 {
9823
9824 if(masked) //if masked, but not stretched
9825 {
9826
9827 if ( rot == 0 ) //if not rotated
9828 {
9829 switch(mode)
9830 {
9831 case 1:
9832 //transparent
9833 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9834 draw_trans_sprite(destbmp, subBmp, dx, dy);
9835 break;
9836
9837
9838 case 2:
9839 //pivot?
9840 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9841 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9842 //Pivoting requires two more args
9843 break;
9844
9845 case 3:
9846 //pivot + trans
9847 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9848 pivot_sprite_trans(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9849 break;
9850
9851 case 4:
9852 //flip v
9853 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9854 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
9855 break;
9856
9857 case 5:
9858 //trans + v flip
9859 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9860 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
9861 break;
9862
9863 case 6:
9864 //pivot + v flip
9865 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9866 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9867 break;
9868
9869 case 8:
9870 //vlip h
9871 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9872 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
9873 break;
9874
9875 case 9:
9876 //trans + h flip
9877 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9878 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
9879 break;
9880
9881 case 10:
9882 //flip H and pivot
9883 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
9884 //return error cannot pivot and h flip
9885 break;
9886
9887 case 12:
9888 //vh flip
9889 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9890 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
9891 break;
9892
9893 case 13:
9894 //trans + vh flip
9895 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9896 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
9897 break;
9898
9899 case 14:
9900 //pivot and vh flip
9901 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
9902 //return error cannot both pivot and vh flip
9903 break;
9904
9905 case 16:
9906 //lit
9907 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9908 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
9909 break;
9910
9911 case 18:
9912 //pivot, lit
9913 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9914 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9915 break;
9916
9917 case 20:
9918 //lit + v flip
9919 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9920 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
9921 break;
9922
9923 case 22:
9924 //Pivot, vflip, lit
9925 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9926 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
9927 break;
9928
9929 case 24:
9930 //lit + h flip
9931 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9932 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
9933 break;
9934
9935 case 26:
9936 //pivot + lit + hflip
9937 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
9938 //return error cannot pivot, lit, and flip
9939 break;
9940
9941 case 28:
9942 //lit + vh flip
9943 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9944 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
9945 break;
9946
9947 case 32: //gouraud
9948 //Probably not wort supporting.
9949 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
9950 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
9951 break;
9952
9953 case 0:
9954 //no effect
9955 masked_blit(srcbmp, destbmp, sx, sy, dx, dy, dw, dh);
9956 break;
9957
9958
9959 default:
9960 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
9961
9962
9963 }
9964 } //end if not rotated
9965
9966 if ( rot != 0 ) //if rotated
9967 {
9968 switch(mode)
9969 {
9970 case 1:
9971 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh); //transparent
9972 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9973
9974 break;
9975
9976 case 2:
9977 //pivot?
9978 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9979 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
9980 //Pivoting requires two more args
9981 break;
9982
9983 case 3:
9984 //pivot + trans
9985 //return an error, cannot both rotate and pivot
9986 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
9987 break;
9988
9989 case 4:
9990 //flip v
9991 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
9992 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9993 break;
9994
9995 case 5:
9996 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh); //trans + v flip
9997 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
9998 break;
9999
10000 case 6:
10001 //pivot + v flip
10002 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10003 //return an error, cannot both rotate and pivot
10004 break;
10005
10006 case 8:
10007 //flip h
10008 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10009 //return an error, cannot both rotate and flip H
10010 break;
10011
10012 case 9:
10013 //trans + h flip
10014 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
10015 //return an error, cannot rotate and flip a trans sprite
10016 break;
10017
10018 case 10:
10019 //flip H and pivot
10020 //return error cannot pivot and h flip
10021 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
10022 break;
10023
10024 case 12:
10025 //vh flip
10026 //return an error, cannot rotate and VH flip a trans sprite
10027 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10028 break;
10029
10030 case 13:
10031 //trans + vh flip
10032 //return an error, cannot rotate and VH flip a trans sprite
10033 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10034 break;
10035
10036 case 14:
10037 //pivot and vh flip
10038 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10039 //return error cannot both pivot and vh flip
10040 break;
10041
10042 case 16:
10043 //lit
10044 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10045 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10046 break;
10047
10048 case 18:
10049 //pivot, lit
10050 //return an error, cannot both rotate and pivot
10051 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10052 break;
10053
10054 case 20:
10055 //lit + vflip
10056 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10057 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10058 break;
10059
10060 case 22:
10061 //Pivot, vflip, lit
10062 //return an error, cannot both rotate and pivot
10063 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10064 break;
10065
10066 case 24:
10067 //lit + h flip
10068 //return an error, cannot both rotate and H flip
10069 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10070 break;
10071
10072 case 26:
10073 //pivot + lit + hflip
10074 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
10075 //return error cannot pivot, lit, and flip
10076 break;
10077
10078 case 28:
10079 //lit + vh flip
10080 //return an error, cannot both rotate and VH flip
10081 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
10082 break;
10083
10084 case 32: //gouraud
10085 //Probably not wort supporting.
10086 //stretch_blit(srcbmp, subBmp, sx, sy, sw, sh, 0, 0, dw, dh);
10087 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
10088 break;
10089
10090 case 0:
10091 //no effect.
10092 masked_blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10093 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10094 break;
10095
10096 default:
10097 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
10098
10099 }
10100 } //end rtated, masked
10101 } //end if masked
10102
10103 else //not masked, and not stretched; just blit
10104 {
10105
10106 if ( rot == 0 ) //if not rotated
10107 {
10108 switch(mode)
10109 {
10110 case 1:
10111 //transparent
10112 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10113 draw_trans_sprite(destbmp, subBmp, dx, dy);
10114 break;
10115
10116
10117 case 2:
10118 //pivot?
10119 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10120 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10121 //Pivoting requires two more args
10122 break;
10123
10124 case 3:
10125 //pivot + trans
10126 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10127 pivot_sprite_trans(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10128 break;
10129
10130 case 4:
10131 //flip v
10132 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10133 draw_sprite_v_flip(destbmp, subBmp, dx, dy);
10134 break;
10135
10136 case 5:
10137 //trans + v flip
10138 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10139 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_V_FLIP);
10140 break;
10141
10142 case 6:
10143 //pivot + v flip
10144 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10145 pivot_sprite_v_flip(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10146 break;
10147
10148 case 8:
10149 //vlip h
10150 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10151 draw_sprite_h_flip(destbmp, subBmp, dx, dy);
10152 break;
10153
10154 case 9:
10155 //trans + h flip
10156 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10157 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_H_FLIP);
10158 break;
10159
10160 case 10:
10161 //flip H and pivot
10162 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
10163 //return error cannot pivot and h flip
10164 break;
10165
10166 case 12:
10167 //vh flip
10168 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10169 draw_sprite_vh_flip(destbmp, subBmp, dx, dy);
10170 break;
10171
10172 case 13:
10173 //trans + vh flip
10174 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10175 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_TRANS, DRAW_SPRITE_VH_FLIP);
10176 break;
10177
10178 case 14:
10179 //pivot and vh flip
10180 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
10181 //return error cannot both pivot and vh flip
10182 break;
10183
10184 case 16:
10185 //lit
10186 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10187 draw_lit_sprite(destbmp, subBmp, dx, dy, litcolour);
10188 break;
10189
10190 case 18:
10191 //pivot, lit
10192 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10193 pivot_sprite_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
10194 break;
10195
10196 case 20:
10197 //lit + v flip
10198 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10199 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_V_FLIP);
10200 break;
10201
10202 case 22:
10203 //Pivot, vflip, lit
10204 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10205 pivot_sprite_v_flip_lit(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot),litcolour);
10206 break;
10207
10208 case 24:
10209 //lit + h flip
10210 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10211 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_H_FLIP);
10212 break;
10213
10214 case 26:
10215 //pivot + lit + hflip
10216 Z_message("Warning: %s cannot both Pivot, Flip, and Lit.\n", funcstr);
10217 //return error cannot pivot, lit, and flip
10218 break;
10219
10220 case 28:
10221 //lit + vh flip
10222 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10223 draw_sprite_ex(destbmp, subBmp, dx, dy, DRAW_SPRITE_LIT, DRAW_SPRITE_VH_FLIP);
10224 break;
10225
10226 case 32: //gouraud
10227 //Probably not wort supporting.
10228 //blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10229 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
10230 break;
10231
10232 case 0:
10233 //no effect
10234 blit(srcbmp, destbmp, sx, sy, dx, dy, dw, dh);
10235 break;
10236
10237
10238 default:
10239 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
10240
10241
10242 }
10243 } //end if not rotated
10244
10245 if ( rot != 0 ) //if rotated
10246 {
10247 switch(mode)
10248 {
10249 case 1:
10250 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);//transparent
10251 rotate_sprite_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10252
10253 break;
10254
10255 case 2:
10256 //pivot?
10257 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10258 pivot_sprite(destbmp, subBmp, dx, dy, cx, cy, degrees_to_fixed(rot));
10259 //Pivoting requires two more args
10260 break;
10261
10262 case 3:
10263 //pivot + trans
10264 //return an error, cannot both rotate and pivot
10265 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10266 break;
10267
10268 case 4:
10269 //flip v
10270 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10271 rotate_sprite_v_flip(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10272 break;
10273
10274 case 5:
10275 //trans + v flip
10276 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10277 rotate_sprite_v_flip_trans(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10278 break;
10279
10280 case 6:
10281 //pivot + v flip
10282 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10283 //return an error, cannot both rotate and pivot
10284 break;
10285
10286 case 8:
10287 //flip h
10288 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10289 //return an error, cannot both rotate and flip H
10290 break;
10291
10292 case 9:
10293 //trans + h flip
10294 Z_message("Warning: %s cannot Rotate and Flip a Trans Sprite.\n", funcstr);
10295 //return an error, cannot rotate and flip a trans sprite
10296 break;
10297
10298 case 10:
10299 //flip H and pivot
10300 //return error cannot pivot and h flip
10301 Z_message("Warning: %s cannot both Pivot and H-Flip.\n", funcstr);
10302 break;
10303
10304 case 12:
10305 //vh flip
10306 //return an error, cannot rotate and VH flip a trans sprite
10307 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10308 break;
10309
10310 case 13:
10311 //trans + vh flip
10312 //return an error, cannot rotate and VH flip a trans sprite
10313 Z_message("Warning: %s cannot both Rotate and VH-Flip.\n", funcstr);
10314 break;
10315
10316 case 14:
10317 //pivot and vh flip
10318 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10319 //return error cannot both pivot and vh flip
10320 break;
10321
10322 case 16:
10323 //lit
10324 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10325 rotate_sprite_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10326 break;
10327
10328 case 18:
10329 //pivot, lit
10330 //return an error, cannot both rotate and pivot
10331 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10332 break;
10333
10334 case 20:
10335 //lit + vflip
10336 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10337 rotate_sprite_v_flip_lit(destbmp, subBmp, dx, dy, degrees_to_fixed(rot),litcolour);
10338 break;
10339
10340 case 22:
10341 //Pivot, vflip, lit
10342 //return an error, cannot both rotate and pivot
10343 Z_message("Warning: %s cannot both Pivot and Rotate.\n", funcstr);
10344 break;
10345
10346 case 24:
10347 //lit + h flip
10348 //return an error, cannot both rotate and H flip
10349 Z_message("Warning: %s cannot both Rotate and H-Flip.\n", funcstr);
10350 break;
10351
10352 case 26:
10353 //pivot + lit + hflip
10354 Z_message("Warning: %s cannot both Pivot and Flip a Lit Sprite.\n", funcstr);
10355 //return error cannot pivot, lit, and flip
10356 break;
10357
10358 case 28:
10359 //lit + vh flip
10360 //return an error, cannot both rotate and VH flip
10361 Z_message("Warning: %s cannot both Pivot and VH-Flip.\n", funcstr);
10362 break;
10363
10364 case 32: //gouraud
10365 //Probably not wort supporting.
10366 //blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10367 //draw_gouraud_sprite(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t c1, int32_t c2, int32_t c3, int32_t c4);
10368 break;
10369
10370 case 0:
10371 //no effect.
10372 blit(srcbmp, subBmp, sx, sy, 0, 0, dw, dh);
10373 rotate_sprite(destbmp, subBmp, dx, dy, degrees_to_fixed(rot));
10374 break;
10375
10376 default:
10377 return Z_message("Warning: %s mode flags not possible in this combination!\n", funcstr);
10378
10379 }
10380 } //end if rotated
10381 } //end if not masked
10382 } //end if not stretched
10383
10384 //cleanup
10385 if(subBmp)
10386 {
10387 //script_drawing_commands.ReleaseSubBitmap(subBmp); //purge the temporary bitmap.
10388 destroy_bitmap(subBmp);
10389 }
10390 destroy_bitmap(srcbmp);
10391 }
10392
10393 void do_comboblit(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool is_bmp)
10394 {
10395 //sdci[2]: combo -> tile
10396 int cid = sdci[2]/10000;
10397 if(unsigned(cid) >= MAXCOMBOS)
10398 {
10399 Z_scripterrlog("ComboBlit tried to draw invalid combo id '%d'\n", cid);
10400 return;
10401 }
10402 sdci[2] = GET_DRAWING_COMBO(cid).tile * 10000;
10403 do_tileblit(bmp, sdci, xoffset, yoffset, is_bmp, "ComboBlit()");
10404 }
10405
10406 void bmp_do_drawquad3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
10407 {
10408
10409 //sdci[1]=layer
10410 //sdci[2]=pos[12]
10411 //sdci[3]=uv[8]
10412 //sdci[4]=color[4]
10413 //sdci[5]=size[2]
10414 //sdci[6]=flip
10415 //sdci[7]=tile/combo
10416 //sdci[8]=polytype
10417 //sdci[9] = other bitmap as texture
10418 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10419 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
10420 {
10421 Z_scripterrlog("bitmap->Quad3D() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
10422 return;
10423 }
10424 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10425 if ( refbmp == NULL ) return;
10426
10427 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
10428
10429 if(!v_ptr)
10430 {
10431 al_trace("Quad3d: Vector pointer is null! Internal error. \n");
10432 return;
10433 }
10434
10435 std::vector<int32_t> &v = *v_ptr;
10436
10437 if(v.empty())
10438 return;
10439
10440 int32_t* pos = &v[0];
10441 int32_t* uv = &v[12];
10442 int32_t* col = &v[20];
10443 int32_t* size = &v[24];
10444
10445 int32_t w = size[0]; //magic numerical constants... yuck.
10446 int32_t h = size[1];
10447 int32_t flip = (sdci[6]/10000)&3;
10448 int32_t tile = sdci[7]/10000;
10449 int32_t polytype = sdci[8]/10000;
10450 int32_t quad_render_source = sdci[9];
10451 Z_scripterrlog("Quad3D texture is %d\n", quad_render_source);
10452
10453 polytype = vbound(polytype, 0, 14);
10454
10455 int32_t tex_width = w*16;
10456 int32_t tex_height = h*16;
10457
10458 bool mustDestroyBmp = false;
10459 BITMAP *tex=NULL;
10460
10461
10462 bool tex_is_bitmap = ( sdci[9] != 0 );
10463 //Z_scripterrlog("sdci[9] is %d\n", quad_render_source);
10464 //Z_scripterrlog("sdci[DRAWCMD_BMP_TARGET] is %d\n", sdci[DRAWCMD_BMP_TARGET]);
10465 BITMAP *bmptexture;
10466
10467 if ( tex_is_bitmap ) bmptexture = resolveScriptingBitmap(quad_render_source);
10468
10469 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10470
10471
10472 if ( !tex_is_bitmap )
10473 {
10474 tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
10475
10476 if(!tex)
10477 {
10478 mustDestroyBmp = true;
10479 tex = create_bitmap_ex(8, tex_width, tex_height);
10480 clear_bitmap(tex);
10481 }
10482 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
10483 {
10484 Z_message("Quad3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
10485 return; //non power of two error
10486 }
10487 if(tile > 0) // TILE
10488 {
10489 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
10490 }
10491 else // COMBO
10492 {
10493 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
10494 const int32_t tiletodraw = combo_tile(c, 0, 0);
10495 flip = flip ^ c.flip;
10496
10497 if(!(c.animflags & AF_EDITOR_ONLY))
10498 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
10499 }
10500
10501 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10502 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10503 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10504 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
10505
10506 quad3d_f(refbmp, polytype, tex, &V1, &V2, &V3, &V4);
10507 if(mustDestroyBmp)
10508 destroy_bitmap(tex);
10509 }
10510 else
10511 {
10512
10513 if ( !bmptexture )
10514 {
10515 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Quad3D()");
10516 tex_is_bitmap = 0;
10517 return;
10518 }
10519 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10520 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10521 if ( !isPowerOfTwo(h) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", h);
10522 if ( !isPowerOfTwo(w) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Quad3D is not a POWER OF TWO.\nTextels may render improperly!\n", w);
10523
10524 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10525 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10526 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10527 V3D_f V4 = { static_cast<float>(pos[9]+xoffset), static_cast<float>(pos[10]+yoffset), static_cast<float>(pos[11]), static_cast<float>(uv[6]), static_cast<float>(uv[7]), col[3] };
10528
10529 BITMAP *foo = create_bitmap_ex(8, 256, 176);
10530
10531 //quad3d_f(refbmp, polytype, foo, &V1, &V2, &V3, &V4);
10532 quad3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3, &V4);
10533 destroy_bitmap(foo);
10534
10535 }
10536
10537
10538
10539 }
10540
10541
10542
10543 void bmp_do_drawtriangle3dr(BITMAP *bmp, int32_t i, int32_t *sdci, int32_t xoffset, int32_t yoffset)
10544 {
10545 //sdci[1]=layer
10546 //sdci[2]=pos[9]
10547 //sdci[3]=uv[6]
10548 //sdci[4]=color[3]
10549 //sdci[5]=size[2]
10550 //sdci[6]=flip
10551 //sdci[7]=tile/combo
10552 //sdci[8]=polytype
10553 //sdci[9] bitmap as texture
10554 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10555 if ( sdci[DRAWCMD_BMP_TARGET] <= 0 )
10556 {
10557 Z_scripterrlog("bitmap->Triangle3D() wanted to write to an invalid bitmap id: %d. Aborting.\n", sdci[DRAWCMD_BMP_TARGET]);
10558 return;
10559 }
10560 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10561 if ( refbmp == NULL ) return;
10562
10563 std::vector<int32_t>* v_ptr = (std::vector<int32_t>*)script_drawing_commands[i].GetPtr();
10564
10565 if(!v_ptr)
10566 {
10567 al_trace("bitmap->Triangle3d: Vector pointer is null! Internal error. \n");
10568 return;
10569 }
10570
10571 std::vector<int32_t> &v = *v_ptr;
10572
10573 if(v.empty())
10574 return;
10575
10576 int32_t* pos = &v[0];
10577 int32_t* uv = &v[9];
10578 int32_t* col = &v[15];
10579 int32_t* size = &v[18];
10580
10581 int32_t w = size[0]; //magic numerical constants... yuck.
10582 int32_t h = size[1];
10583 int32_t flip = (sdci[6]/10000)&3;
10584 int32_t tile = sdci[7]/10000;
10585 int32_t polytype = sdci[8]/10000;
10586 int32_t quad_render_source = sdci[9];
10587 polytype = vbound(polytype, 0, 14);
10588
10589 if(((w-1) & w) != 0 || ((h-1) & h) != 0)
10590 {
10591 Z_message("bitmap->Triangle3d() : Args h, w, must be in powers of two! Power of 2 error with %i, %i.", w, h);
10592 return; //non power of two error
10593 }
10594
10595 int32_t tex_width = w*16;
10596 int32_t tex_height = h*16;
10597
10598 bool mustDestroyBmp = false;
10599 BITMAP *tex = script_drawing_commands.GetSmallTextureBitmap(w,h);
10600
10601 if(!tex)
10602 {
10603 mustDestroyBmp = true;
10604 tex = create_bitmap_ex(8, tex_width, tex_height);
10605 clear_bitmap(tex);
10606 }
10607
10608 bool tex_is_bitmap = ( sdci[9] != 0 );
10609 BITMAP *bmptexture=NULL;
10610 if ( tex_is_bitmap )
10611 {
10612 bmptexture = resolveScriptingBitmap(quad_render_source);
10613 if ( !bmptexture )
10614 {
10615 Z_scripterrlog("Bitmap pointer used as a texture in %s is uninitialised.\n Defaulting to using a tile as a texture.\n", "bitmap->Triangle3()");
10616 tex_is_bitmap = 0;
10617 }
10618 }
10619
10620 if ( !tex_is_bitmap )
10621 {
10622 if(tile > 0) // TILE
10623 {
10624 TileHelper::OverTile(tex, tile, 0, 0, w, h, col[0], flip);
10625 }
10626 else // COMBO
10627 {
10628 auto& c = GET_DRAWING_COMBO(vbound(abs(tile), 0, 0xffff));
10629 const int32_t tiletodraw = combo_tile(c, 0, 0);
10630 flip = flip ^ c.flip;
10631
10632 if(!(c.animflags & AF_EDITOR_ONLY))
10633 TileHelper::OldPutTile(tex, tiletodraw, 0, 0, w, h, col[0], flip);
10634 }
10635
10636 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10637 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10638 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10639
10640 triangle3d_f(refbmp, polytype, tex, &V1, &V2, &V3);
10641 }
10642 else
10643 {
10644 if ( !isPowerOfTwo(bmptexture->h) ) Z_scripterrlog("HEIGHT of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10645 if ( !isPowerOfTwo(bmptexture->w) ) Z_scripterrlog("WIDTH of Bitmap ( pointer %d ) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", quad_render_source);
10646 if ( !isPowerOfTwo(w) ) Z_scripterrlog("WIDTH ARG (%d) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", w);
10647 if ( !isPowerOfTwo(h) ) Z_scripterrlog("HEIGHT ARG (%d) provided as a render source for bitmap->Triangle3D is not a POWER OF TWO.\nTextels may render improperly!\n", h);
10648
10649 V3D_f V1 = { static_cast<float>(pos[0]+xoffset), static_cast<float>(pos[1] +yoffset), static_cast<float>(pos[2]), static_cast<float>(uv[0]), static_cast<float>(uv[1]), col[0] };
10650 V3D_f V2 = { static_cast<float>(pos[3]+xoffset), static_cast<float>(pos[4] +yoffset), static_cast<float>(pos[5]), static_cast<float>(uv[2]), static_cast<float>(uv[3]), col[1] };
10651 V3D_f V3 = { static_cast<float>(pos[6]+xoffset), static_cast<float>(pos[7] +yoffset), static_cast<float>(pos[8]), static_cast<float>(uv[4]), static_cast<float>(uv[5]), col[2] };
10652
10653 triangle3d_f(refbmp, polytype, bmptexture, &V1, &V2, &V3);
10654
10655
10656 }
10657 if(mustDestroyBmp)
10658 destroy_bitmap(tex);
10659
10660 }
10661
10662
10663 bool is_layer_transparent(const mapscr& m, int32_t layer)
10664 {
10665 layer = vbound(layer, 0, 5);
10666 return m.layeropacity[layer] == 128;
10667 }
10668
10669 4513893 mapscr *getmapscreen(int32_t map_index, int32_t screen, int32_t layer) //returns NULL for invalid or non-existent layer
10670 {
10671 mapscr *base_scr;
10672 4513893 int32_t index = map_index*MAPSCRS+screen;
10673
10674
2/4
✓ Branch 0 taken 4513893 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 4513893 times.
4513893 if((uint32_t)layer > 6 || (uint32_t)index >= TheMaps.size())
10675 return NULL;
10676
10677
2/2
✓ Branch 0 taken 3579197 times.
✓ Branch 1 taken 934696 times.
4513893 if(layer != 0)
10678 {
10679 934696 layer = layer - 1;
10680
10681 934696 base_scr=&(TheMaps[index]);
10682
10683
2/2
✓ Branch 0 taken 842046 times.
✓ Branch 1 taken 92650 times.
934696 if(base_scr->layermap[layer]==0)
10684 92650 return NULL;
10685
10686 842046 index=(base_scr->layermap[layer]-1)*MAPSCRS+base_scr->layerscreen[layer];
10687
10688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 842046 times.
842046 if((uint32_t)index >= TheMaps.size()) // Might as well make sure
10689 return NULL;
10690 842046 }
10691
10692 4421243 return &(TheMaps[index]);
10693 4513893 }
10694
10695 659237800 static bool transparent_combo(int32_t id)
10696 {
10697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 659237800 times.
659237800 if(unsigned(id) >= MAXCOMBOS) return false;
10698 659237800 return bool(combobuf[id].animflags & AF_TRANSPARENT);
10699 659237800 }
10700
10701 199800 void draw_mapscr(BITMAP *b, const mapscr& m, int32_t x, int32_t y, bool transparent)
10702 {
10703
2/2
✓ Branch 0 taken 35164800 times.
✓ Branch 1 taken 199800 times.
35364600 for(int32_t i(0); i < 176; ++i)
10704 {
10705 35164800 const int32_t x2 = ((i&15)<<4) + x;
10706 35164800 const int32_t y2 = (i&0xF0) + y;
10707
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35164800 times.
35164800 if(combobuf[m.data[i]].animflags & AF_EDITOR_ONLY) continue;
10708
10709
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 35164800 times.
35164800 if(transparent != transparent_combo(m.data[i]))
10710 {
10711 overcomboblocktranslucent(b, x2, y2, m.data[i], m.cset[i], 1, 1, 128);
10712 }
10713 else
10714 {
10715 35164800 overcomboblock(b, x2, y2, m.data[i], m.cset[i], 1, 1);
10716 }
10717 35164800 }
10718 199800 }
10719
10720 void draw_map_solidity(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10721 {
10722 BITMAP* square = create_bitmap_ex(8,16,16);
10723
10724 for(int32_t i(0); i < 176; ++i)
10725 {
10726 const int32_t x2 = ((i&15)<<4) + x;
10727 const int32_t y2 = (i&0xF0) + y;
10728 //Blit the palette index of the solidity value.
10729 clear_to_color(square,(combobuf[m.data[i]].walk&15));
10730 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
10731 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
10732 }
10733 destroy_bitmap(square);
10734 }
10735
10736 void do_bmpdrawscreen_solidmaskr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10737 {
10738 //sdci[1]=layer
10739 //sdci[2]=map
10740 //sdci[3]=screen
10741 //sdci[4]=x
10742 //sdci[5]=y
10743 //sdci[6]=rotation
10744 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10745
10746 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10747 if ( refbmp == NULL ) return;
10748
10749 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10750
10751 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10752 int32_t screen = sdci[3]/10000;
10753 int32_t x = sdci[4]/10000;
10754 int32_t y = sdci[5]/10000;
10755 int32_t x1 = x + xoffset;
10756 int32_t y1 = y + yoffset;
10757 int32_t rotation = sdci[6]/10000;
10758 uint32_t index = (uint32_t)map_screen_index(map, screen);
10759
10760 if(index >= TheMaps.size())
10761 {
10762 al_trace("DrawScreen: invalid map or screen index. \n");
10763 return;
10764 }
10765
10766 const mapscr & m = TheMaps[index];
10767
10768
10769 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10770 if ( refbmp == NULL ) return;
10771
10772 if(rotation != 0)
10773 b = script_drawing_commands.AquireSubBitmap(256, 176);
10774
10775 //draw layer 0
10776 draw_map_solidity(b, m, x1, y1);
10777 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
10778 {
10779 for(int32_t i(0); i < 6; ++i)
10780 {
10781 if(m.layermap[i] == 0) continue;
10782
10783 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10784
10785 if(layer_screen_index >= TheMaps.size())
10786 continue;
10787
10788 //draw valid layers
10789 draw_map_solidity(b, TheMaps[ layer_screen_index ], x1, y1);
10790 }
10791 }
10792
10793 if(rotation != 0) // rotate
10794 {
10795 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10796 script_drawing_commands.ReleaseSubBitmap(b);
10797 }
10798 }
10799
10800 void draw_map_solid(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10801 {
10802 BITMAP* square = create_bitmap_ex(8,16,16);
10803 BITMAP* subsquare = create_bitmap_ex(8,16,16);
10804 clear_to_color(subsquare,1);
10805
10806 for(int32_t i(0); i < 176; ++i)
10807 {
10808 const int32_t x2 = ((i&15)<<4) + x;
10809 const int32_t y2 = (i&0xF0) + y;
10810 //Blit the palette index of the solidity value.
10811 clear_bitmap(square);
10812 int32_t sol = (combobuf[m.data[i]].walk);
10813 if ( sol & 1 )
10814 {
10815 blit(subsquare, square, 0, 0, 0, 0, 8, 8);
10816 }
10817 if ( sol & 2 )
10818 {
10819 blit(subsquare, square, 0, 0, 0, 8, 8, 8);
10820 }
10821 if ( sol & 4 )
10822 {
10823 blit(subsquare, square, 0, 0, 8, 0, 8, 8);
10824 }
10825 if ( sol &8 ) {
10826 blit(subsquare, square, 0, 0, 8, 8, 8, 8);
10827 }
10828
10829 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
10830 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
10831 }
10832 destroy_bitmap(square);
10833 destroy_bitmap(subsquare);
10834 }
10835
10836 void do_bmpdrawscreen_solidr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10837 {
10838 //sdci[1]=layer
10839 //sdci[2]=map
10840 //sdci[3]=screen
10841 //sdci[4]=x
10842 //sdci[5]=y
10843 //sdci[6]=rotation
10844 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10845
10846 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10847 if ( refbmp == NULL ) return;
10848
10849 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10850
10851 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10852 int32_t screen = sdci[3]/10000;
10853 int32_t x = sdci[4]/10000;
10854 int32_t y = sdci[5]/10000;
10855 int32_t x1 = x + xoffset;
10856 int32_t y1 = y + yoffset;
10857 int32_t rotation = sdci[6]/10000;
10858
10859 uint32_t index = (uint32_t)map_screen_index(map, screen);
10860
10861 if(index >= TheMaps.size())
10862 {
10863 al_trace("DrawScreen: invalid map or screen index. \n");
10864 return;
10865 }
10866
10867 const mapscr & m = TheMaps[index];
10868
10869
10870 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10871 if ( refbmp == NULL ) return;
10872
10873 if(rotation != 0)
10874 b = script_drawing_commands.AquireSubBitmap(256, 176);
10875
10876 //draw layer 0
10877 draw_map_solid(b, m, x1, y1);
10878
10879 for(int32_t i(0); i < 6; ++i) //This one doesn't need the QR; it works just fine.
10880 {
10881 if(m.layermap[i] == 0) continue;
10882
10883 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10884
10885 if(layer_screen_index >= TheMaps.size())
10886 continue;
10887
10888 //draw valid layers
10889 draw_map_solid(b, TheMaps[ layer_screen_index ], x1, y1);
10890 }
10891
10892 if(rotation != 0) // rotate
10893 {
10894 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10895 script_drawing_commands.ReleaseSubBitmap(b);
10896 }
10897 }
10898
10899 1024 void draw_map_cflag(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10900 {
10901 1024 BITMAP* square = create_bitmap_ex(8,16,16);
10902
10903
2/2
✓ Branch 0 taken 180224 times.
✓ Branch 1 taken 1024 times.
181248 for(int32_t i(0); i < 176; ++i)
10904 {
10905 180224 const int32_t x2 = ((i&15)<<4) + x;
10906 180224 const int32_t y2 = (i&0xF0) + y;
10907 //Blit the palette index of the solidity value.
10908 180224 clear_to_color(square,m.sflag[i]);
10909
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 180224 times.
180224 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
10910 180224 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
10911 180224 }
10912 1024 destroy_bitmap(square);
10913 1024 }
10914
10915 1024 void do_bmpdrawscreen_cflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10916 {
10917 //sdci[1]=layer
10918 //sdci[2]=map
10919 //sdci[3]=screen
10920 //sdci[4]=x
10921 //sdci[5]=y
10922 //sdci[6]=rotation
10923 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
10924
10925 1024 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10926
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if ( refbmp == NULL ) return;
10927
10928
2/4
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1024 times.
✗ Branch 3 not taken.
1024 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
10929
10930 1024 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
10931 1024 int32_t screen = sdci[3]/10000;
10932 1024 int32_t x = sdci[4]/10000;
10933 1024 int32_t y = sdci[5]/10000;
10934 1024 int32_t x1 = x + xoffset;
10935 1024 int32_t y1 = y + yoffset;
10936 1024 int32_t rotation = sdci[6]/10000;
10937
10938 1024 uint32_t index = (uint32_t)map_screen_index(map, screen);
10939
10940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1024 times.
1024 if(index >= TheMaps.size())
10941 {
10942 al_trace("DrawScreen: invalid map or screen index. \n");
10943 return;
10944 }
10945
10946 1024 const mapscr & m = TheMaps[index];
10947
10948
10949 1024 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
10950
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if ( refbmp == NULL ) return;
10951
10952
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(rotation != 0)
10953 b = script_drawing_commands.AquireSubBitmap(256, 176);
10954
10955 //draw layer 0
10956 1024 draw_map_cflag(b, m, x1, y1);
10957
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
10958 {
10959 for(int32_t i(0); i < 6; ++i)
10960 {
10961 if(m.layermap[i] == 0) continue;
10962
10963 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
10964
10965 if(layer_screen_index >= TheMaps.size())
10966 continue;
10967
10968 //draw valid layers
10969 draw_map_cflag(b, TheMaps[ layer_screen_index ], x1, y1);
10970 }
10971 }
10972
10973
1/2
✓ Branch 0 taken 1024 times.
✗ Branch 1 not taken.
1024 if(rotation != 0) // rotate
10974 {
10975 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
10976 script_drawing_commands.ReleaseSubBitmap(b);
10977 }
10978 1024 }
10979
10980
10981 void draw_map_combotype(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
10982 {
10983 BITMAP* square = create_bitmap_ex(8,16,16);
10984
10985 for(int32_t i(0); i < 176; ++i)
10986 {
10987 const int32_t x2 = ((i&15)<<4) + x;
10988 const int32_t y2 = (i&0xF0) + y;
10989 //Blit the palette index of the solidity value.
10990 clear_to_color(square,(combobuf[m.data[i]].type));
10991 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
10992 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
10993 }
10994 destroy_bitmap(square);
10995 }
10996
10997 void do_bmpdrawscreen_ctyper(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
10998 {
10999 //sdci[1]=layer
11000 //sdci[2]=map
11001 //sdci[3]=screen
11002 //sdci[4]=x
11003 //sdci[5]=y
11004 //sdci[6]=rotation
11005 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11006
11007 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11008 if ( refbmp == NULL ) return;
11009
11010 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11011
11012 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11013 int32_t screen = sdci[3]/10000;
11014 int32_t x = sdci[4]/10000;
11015 int32_t y = sdci[5]/10000;
11016 int32_t x1 = x + xoffset;
11017 int32_t y1 = y + yoffset;
11018 int32_t rotation = sdci[6]/10000;
11019
11020 uint32_t index = (uint32_t)map_screen_index(map, screen);
11021
11022 if(index >= TheMaps.size())
11023 {
11024 al_trace("DrawScreen: invalid map or screen index. \n");
11025 return;
11026 }
11027
11028 const mapscr & m = TheMaps[index];
11029
11030
11031 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11032 if ( refbmp == NULL ) return;
11033
11034 if(rotation != 0)
11035 b = script_drawing_commands.AquireSubBitmap(256, 176);
11036
11037 //draw layer 0
11038 draw_map_combotype(b, m, x1, y1);
11039
11040 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
11041 {
11042 for(int32_t i(0); i < 6; ++i)
11043 {
11044 if(m.layermap[i] == 0) continue;
11045
11046 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11047
11048 if(layer_screen_index >= TheMaps.size())
11049 continue;
11050
11051 //draw valid layers
11052 draw_map_combotype(b, TheMaps[ layer_screen_index ], x1, y1);
11053 }
11054 }
11055
11056 if(rotation != 0) // rotate
11057 {
11058 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
11059 script_drawing_commands.ReleaseSubBitmap(b);
11060 }
11061 }
11062
11063
11064 void draw_map_comboiflag(BITMAP *b, const mapscr& m, int32_t x, int32_t y)
11065 {
11066 BITMAP* square = create_bitmap_ex(8,16,16);
11067
11068 for(int32_t i(0); i < 176; ++i)
11069 {
11070 const int32_t x2 = ((i&15)<<4) + x;
11071 const int32_t y2 = (i&0xF0) + y;
11072 //Blit the palette index of the solidity value.
11073 clear_to_color(square,(combobuf[m.data[i]].flag));
11074 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS)) blit(square, b, 0, 0, x2, y2, square->w, square->h);
11075 else masked_blit(square, b, 0, 0, x2, y2, square->w, square->h);
11076 }
11077 destroy_bitmap(square);
11078 }
11079
11080 void do_bmpdrawscreen_ciflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11081 {
11082 //sdci[1]=layer
11083 //sdci[2]=map
11084 //sdci[3]=screen
11085 //sdci[4]=x
11086 //sdci[5]=y
11087 //sdci[6]=rotation
11088 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11089
11090 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11091 if ( refbmp == NULL ) return;
11092
11093 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11094
11095 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11096 int32_t screen = sdci[3]/10000;
11097 int32_t x = sdci[4]/10000;
11098 int32_t y = sdci[5]/10000;
11099 int32_t x1 = x + xoffset;
11100 int32_t y1 = y + yoffset;
11101 int32_t rotation = sdci[6]/10000;
11102
11103 uint32_t index = (uint32_t)map_screen_index(map, screen);
11104
11105 if(index >= TheMaps.size())
11106 {
11107 al_trace("DrawScreen: invalid map or screen index. \n");
11108 return;
11109 }
11110
11111 const mapscr & m = TheMaps[index];
11112
11113
11114 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11115 if ( refbmp == NULL ) return;
11116
11117 if(rotation != 0)
11118 b = script_drawing_commands.AquireSubBitmap(256, 176);
11119
11120 //draw layer 0
11121 draw_map_comboiflag(b, m, x1, y1);
11122
11123 if (get_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS))
11124 {
11125 for(int32_t i(0); i < 6; ++i)
11126 {
11127 if(m.layermap[i] == 0) continue;
11128
11129 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11130
11131 if(layer_screen_index >= TheMaps.size())
11132 continue;
11133
11134 //draw valid layers
11135 draw_map_comboiflag(b, TheMaps[ layer_screen_index ], x1, y1);
11136 }
11137 }
11138
11139 if(rotation != 0) // rotate
11140 {
11141 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
11142 script_drawing_commands.ReleaseSubBitmap(b);
11143 }
11144 }
11145
11146 4370235 void do_drawlayerr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11147 {
11148 //sdci[1]=layer
11149 //sdci[2]=map
11150 //sdci[3]=screen
11151 //sdci[4]=layer
11152 //sdci[5]=x
11153 //sdci[6]=y
11154 //sdci[7]=rotation
11155 //sdci[8]=opacity
11156
11157 4370235 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11158 4370235 int32_t screen = sdci[3]/10000;
11159 4370235 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11160 4370235 int32_t x = sdci[5]/10000;
11161 4370235 int32_t y = sdci[6]/10000;
11162 4370235 int32_t x1 = x + xoffset;
11163 4370235 int32_t y1 = y + yoffset;
11164 4370235 int32_t rotation = sdci[7]/10000;
11165 4370235 int32_t opacity = sdci[8]/10000;
11166
11167 4370235 uint32_t index = (uint32_t)map_screen_index(map, screen);
11168 4370235 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11169
11170
2/2
✓ Branch 0 taken 4318301 times.
✓ Branch 1 taken 51934 times.
4370235 if(!m) //no need to log it.
11171 51934 return;
11172
11173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4318301 times.
4318301 if(index >= TheMaps.size())
11174 {
11175 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11176 return;
11177 }
11178
11179 4318301 const mapscr & l = *m;
11180
11181 4318301 BITMAP* b = bmp;
11182
11183
1/2
✓ Branch 0 taken 4318301 times.
✗ Branch 1 not taken.
4318301 if(rotation != 0)
11184 b = script_drawing_commands.AquireSubBitmap(256, 176);
11185
11186
11187 4318301 const int32_t maxX = isOffScreen ? 512 : 256;
11188
2/2
✓ Branch 0 taken 4298918 times.
✓ Branch 1 taken 19383 times.
4318301 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11189 4318301 bool transparent = opacity <= 128;
11190
11191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4318301 times.
4318301 if(rotation != 0) // rotate
11192 {
11193 draw_mapscr(b, l, x1, y1, transparent);
11194
11195 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11196 script_drawing_commands.ReleaseSubBitmap(b);
11197 }
11198 else
11199 {
11200
2/2
✓ Branch 0 taken 760020976 times.
✓ Branch 1 taken 4318301 times.
764339277 for(int32_t i(0); i < 176; ++i)
11201 {
11202 760020976 const int32_t x2 = ((i&15)<<4) + x1;
11203 760020976 const int32_t y2 = (i&0xF0) + y1;
11204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 760020976 times.
760020976 if(combobuf[l.data[i]].animflags & AF_EDITOR_ONLY) continue;
11205
11206
7/8
✓ Branch 0 taken 669516342 times.
✓ Branch 1 taken 90504634 times.
✓ Branch 2 taken 669516342 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 615110950 times.
✓ Branch 5 taken 54405392 times.
✓ Branch 6 taken 9155742 times.
✓ Branch 7 taken 605955208 times.
760020976 if(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY) //in clipping rect
11207 {
11208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 605955208 times.
605955208 if(opacity < 128 != transparent_combo(l.data[i]))
11209 {
11210 overcomboblocktranslucent(b, x2, y2, l.data[i], l.cset[i], 1, 1, 128);
11211 }
11212 else
11213 {
11214 605955208 overcomboblock(b, x2, y2, l.data[i], l.cset[i], 1, 1);
11215 }
11216 605955208 }
11217 760020976 }
11218 }
11219
11220 //putscr
11221 4370235 }
11222
11223
11224
11225 50406 void do_drawscreenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11226 {
11227 //sdci[1]=layer
11228 //sdci[2]=map
11229 //sdci[3]=screen
11230 //sdci[4]=x
11231 //sdci[5]=y
11232 //sdci[6]=rotation
11233
11234 50406 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11235 50406 int32_t screen = sdci[3]/10000;
11236 50406 int32_t x = sdci[4]/10000;
11237 50406 int32_t y = sdci[5]/10000;
11238 50406 int32_t x1 = x + xoffset;
11239 50406 int32_t y1 = y + yoffset;
11240 50406 int32_t rotation = sdci[6]/10000;
11241
11242 50406 uint32_t index = (uint32_t)map_screen_index(map, screen);
11243
11244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50406 times.
50406 if(index >= TheMaps.size())
11245 {
11246 al_trace("DrawScreen: invalid map or screen index. \n");
11247 return;
11248 }
11249
11250 50406 const mapscr & m = TheMaps[index];
11251
11252
11253 50406 BITMAP* b = bmp;
11254
11255
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50406 times.
50406 if(rotation != 0)
11256 b = script_drawing_commands.AquireSubBitmap(256, 176);
11257
11258 //draw layer 0
11259 50406 draw_mapscr(b, m, x1, y1, false);
11260
11261
2/2
✓ Branch 0 taken 50406 times.
✓ Branch 1 taken 302436 times.
352842 for(int32_t i(0); i < 6; ++i)
11262 {
11263
2/2
✓ Branch 0 taken 137944 times.
✓ Branch 1 taken 164492 times.
302436 if(m.layermap[i] == 0) continue;
11264
11265 137944 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11266
11267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 137944 times.
137944 if(layer_screen_index >= TheMaps.size())
11268 continue;
11269
11270 137944 bool trans = m.layeropacity[i] == 128;
11271
11272 //draw valid layers
11273 137944 draw_mapscr(b, TheMaps[ layer_screen_index ], x1, y1, trans);
11274 137944 }
11275
11276
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 50406 times.
50406 if(rotation != 0) // rotate
11277 {
11278 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11279 script_drawing_commands.ReleaseSubBitmap(b);
11280 }
11281 50406 }
11282
11283
11284 143658 void do_bmpdrawlayerr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11285 {
11286 //sdci[1]=layer
11287 //sdci[2]=map
11288 //sdci[3]=screen
11289 //sdci[4]=layer
11290 //sdci[5]=x
11291 //sdci[6]=y
11292 //sdci[7]=rotation
11293 //[8] noclip
11294 //sdci[9]=opacity
11295 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11296
11297 143658 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11298
1/2
✓ Branch 0 taken 143658 times.
✗ Branch 1 not taken.
143658 if ( refbmp == NULL ) return;
11299
11300 143658 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11301 143658 int32_t screen = sdci[3]/10000;
11302 143658 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11303 143658 int32_t x = sdci[5]/10000;
11304 143658 int32_t y = sdci[6]/10000;
11305 143658 int32_t rotation = sdci[7]/10000;
11306
11307 143658 byte noclip = 0;//(sdci[8]!=0);
11308 143658 int32_t opacity = sdci[8]/10000;
11309 143658 uint32_t index = (uint32_t)map_screen_index(map, screen);
11310 143658 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11311
11312
2/2
✓ Branch 0 taken 102942 times.
✓ Branch 1 taken 40716 times.
143658 if(!m) //no need to log it.
11313 40716 return;
11314
11315
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102942 times.
102942 if(index >= TheMaps.size())
11316 {
11317 Z_scripterrlog("DrawLayer: invalid map index \"%i\". Map count is %zu.\n", index, TheMaps.size());
11318 return;
11319 }
11320
11321 102942 const mapscr & l = *m;
11322
11323 102942 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11324
1/2
✓ Branch 0 taken 102942 times.
✗ Branch 1 not taken.
102942 if ( refbmp == NULL ) return;
11325
2/4
✓ Branch 0 taken 102942 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 102942 times.
✗ Branch 3 not taken.
102942 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11326
1/2
✓ Branch 0 taken 102942 times.
✗ Branch 1 not taken.
102942 if(rotation != 0)
11327 b = script_drawing_commands.AquireSubBitmap(256, 176);
11328
11329
11330 102942 const int32_t maxX = isOffScreen ? 512 : 256;
11331
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102942 times.
102942 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11332 102942 bool transparent = opacity <= 128;
11333
11334
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 102942 times.
102942 if(rotation != 0) // rotate
11335 {
11336 draw_mapscr(b, l, x, y, transparent);
11337
11338 rotate_sprite(refbmp, b, x, y, degrees_to_fixed(rotation));
11339 script_drawing_commands.ReleaseSubBitmap(b);
11340 }
11341 else
11342 {
11343
2/2
✓ Branch 0 taken 18117792 times.
✓ Branch 1 taken 102942 times.
18220734 for(int32_t i(0); i < 176; ++i)
11344 {
11345 18117792 const int32_t x2 = ((i&15)<<4) + x;
11346 18117792 const int32_t y2 = (i&0xF0) + y;
11347
11348 //if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11349 {
11350 18117792 auto& c = GET_DRAWING_COMBO(l.data[i]);
11351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18117792 times.
18117792 if(c.animflags & AF_EDITOR_ONLY) continue;
11352 18117792 const int32_t tile = combo_tile(c, x2, y2);
11353
11354
2/2
✓ Branch 0 taken 37572 times.
✓ Branch 1 taken 18080220 times.
18117792 if(opacity < 128 != transparent_combo(l.data[i]))
11355 37572 overtiletranslucent16(refbmp, tile, x2, y2, l.cset[i], c.flip, opacity);
11356 else
11357 18080220 overtile16(refbmp, tile, x2, y2, l.cset[i], c.flip);
11358
11359 //putcombo( b, xx, yy, l.data[i], l.cset[i] );
11360 }
11361 18117792 }
11362 }
11363
11364 //putscr
11365 143658 }
11366
11367
11368
11369 2740 void do_bmpdrawscreenr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11370 {
11371 //sdci[1]=layer
11372 //sdci[2]=map
11373 //sdci[3]=screen
11374 //sdci[4]=x
11375 //sdci[5]=y
11376 //sdci[6]=rotation
11377 //sdci[DRAWCMD_BMP_TARGET] Bitmap Pointer
11378
11379 2740 BITMAP *refbmp = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11380
1/2
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
2740 if ( refbmp == NULL ) return;
11381
11382
2/4
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2740 times.
2740 if ( (sdci[DRAWCMD_BMP_TARGET]-10) != -2 && (sdci[DRAWCMD_BMP_TARGET]-10) != -1 ) yoffset = 0; //Don't crop.
11383
11384 2740 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11385 2740 int32_t screen = sdci[3]/10000;
11386 2740 int32_t x = sdci[4]/10000;
11387 2740 int32_t y = sdci[5]/10000;
11388 2740 int32_t x1 = x + xoffset;
11389 2740 int32_t y1 = y + yoffset;
11390 2740 int32_t rotation = sdci[6]/10000;
11391
11392 2740 uint32_t index = (uint32_t)map_screen_index(map, screen);
11393
11394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2740 times.
2740 if(index >= TheMaps.size())
11395 {
11396 al_trace("DrawScreen: invalid map or screen index. \n");
11397 return;
11398 }
11399
11400 2740 const mapscr & m = TheMaps[index];
11401
11402
11403 2740 BITMAP* b = resolveScriptingBitmap(sdci[DRAWCMD_BMP_TARGET]);
11404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2740 times.
2740 if ( refbmp == NULL ) return;
11405
11406
1/2
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
2740 if(rotation != 0)
11407 b = script_drawing_commands.AquireSubBitmap(256, 176);
11408
11409 //draw layer 0
11410 2740 draw_mapscr(b, m, x1, y1, false);
11411
11412
2/2
✓ Branch 0 taken 2740 times.
✓ Branch 1 taken 16440 times.
19180 for(int32_t i(0); i < 6; ++i)
11413 {
11414
2/2
✓ Branch 0 taken 8710 times.
✓ Branch 1 taken 7730 times.
16440 if(m.layermap[i] == 0) continue;
11415
11416 8710 uint32_t layer_screen_index = (m.layermap[i]-1) * MAPSCRS + m.layerscreen[i];
11417
11418
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8710 times.
8710 if(layer_screen_index >= TheMaps.size())
11419 continue;
11420
11421 8710 bool trans = m.layeropacity[i] == 128;
11422
11423 //draw valid layers
11424 8710 draw_mapscr(b, TheMaps[ layer_screen_index ], x1, y1, trans);
11425 8710 }
11426
11427
1/2
✓ Branch 0 taken 2740 times.
✗ Branch 1 not taken.
2740 if(rotation != 0) // rotate
11428 {
11429 rotate_sprite(refbmp, b, x1, y1, degrees_to_fixed(rotation));
11430 script_drawing_commands.ReleaseSubBitmap(b);
11431 }
11432 2740 }
11433
11434 void do_bmpdrawlayersolidmaskr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11435 {
11436 //sdci[1]=layer
11437 //sdci[2]=map
11438 //sdci[3]=screen
11439 //sdci[4]=layer
11440 //sdci[5]=x
11441 //sdci[6]=y
11442 //sdci[7]=rotation
11443 //sdci[8]=bool noclip
11444 //sdci[9] == opacity
11445
11446 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11447 int32_t screen = sdci[3]/10000;
11448 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11449 int32_t x = sdci[5]/10000;
11450 int32_t y = sdci[6]/10000;
11451 int32_t x1 = x + xoffset;
11452 int32_t y1 = y + yoffset;
11453 int32_t rotation = sdci[7]/10000;
11454 byte noclip = (sdci[8]!=0);
11455 int32_t opacity = sdci[9]/10000;
11456
11457 uint32_t index = (uint32_t)map_screen_index(map, screen);
11458 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11459
11460 if(!m) //no need to log it.
11461 return;
11462
11463 if(index >= TheMaps.size())
11464 {
11465 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11466 return;
11467 }
11468
11469 const mapscr & l = *m;
11470
11471 BITMAP* b = bmp;
11472
11473 if(rotation != 0)
11474 b = script_drawing_commands.AquireSubBitmap(256, 176);
11475
11476
11477 const int32_t maxX = isOffScreen ? 512 : 256;
11478 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11479 bool transparent = opacity <= 128;
11480
11481 if(rotation != 0) // rotate
11482 {
11483 draw_map_solid(b, l, x1, y1);
11484
11485 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11486 script_drawing_commands.ReleaseSubBitmap(b);
11487 }
11488 else
11489 {
11490 BITMAP* square = create_bitmap_ex(8,16,16);
11491 BITMAP* subsquare = create_bitmap_ex(8,16,16);
11492 clear_to_color(subsquare,1);
11493 for(int32_t i(0); i < 176; ++i)
11494 {
11495 const int32_t x2 = ((i&15)<<4) + x1;
11496 const int32_t y2 = (i&0xF0) + y1;
11497
11498 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11499 {
11500 int32_t sol = (combobuf[l.data[i]].walk);
11501
11502 if ( sol & 1 )
11503 {
11504 blit(subsquare, square, 0, 0, 0, 0, 8, 8);
11505 }
11506 if ( sol & 2 )
11507 {
11508 blit(subsquare, square, 0, 0, 0, 8, 8, 8);
11509 }
11510 if ( sol & 4 )
11511 {
11512 blit(subsquare, square, 0, 0, 8, 0, 8, 8);
11513 }
11514 if ( sol &8 ) {
11515 blit(subsquare, square, 0, 0, 8, 8, 8, 8);
11516 }
11517
11518 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11519 }
11520 }
11521 destroy_bitmap(square);
11522 destroy_bitmap(subsquare);
11523 }
11524
11525 //putscr
11526 }
11527
11528 void do_bmpdrawlayersolidityr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11529 {
11530 //sdci[1]=layer
11531 //sdci[2]=map
11532 //sdci[3]=screen
11533 //sdci[4]=layer
11534 //sdci[5]=x
11535 //sdci[6]=y
11536 //sdci[7]=rotation
11537 //[8] noclip
11538 //sdci[9]=opacity
11539
11540
11541 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11542 int32_t screen = sdci[3]/10000;
11543 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11544 int32_t x = sdci[5]/10000;
11545 int32_t y = sdci[6]/10000;
11546 int32_t x1 = x + xoffset;
11547 int32_t y1 = y + yoffset;
11548 int32_t rotation = sdci[7]/10000;
11549 byte noclip = (sdci[8]!=0);
11550 int32_t opacity = sdci[9]/10000;
11551
11552 uint32_t index = (uint32_t)map_screen_index(map, screen);
11553 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11554
11555 if(!m) //no need to log it.
11556 return;
11557
11558 if(index >= TheMaps.size())
11559 {
11560 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11561 return;
11562 }
11563
11564 const mapscr & l = *m;
11565
11566 BITMAP* b = bmp;
11567
11568 if(rotation != 0)
11569 b = script_drawing_commands.AquireSubBitmap(256, 176);
11570
11571
11572 const int32_t maxX = isOffScreen ? 512 : 256;
11573 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11574 bool transparent = opacity <= 128;
11575
11576 if(rotation != 0) // rotate
11577 {
11578 draw_map_solidity(b, l, x1, y1);
11579
11580 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11581 script_drawing_commands.ReleaseSubBitmap(b);
11582 }
11583 else
11584 {
11585 BITMAP* square = create_bitmap_ex(8,16,16);
11586 for(int32_t i(0); i < 176; ++i)
11587 {
11588 const int32_t x2 = ((i&15)<<4) + x1;
11589 const int32_t y2 = (i&0xF0) + y1;
11590
11591 if(noclip && (x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11592 {
11593 clear_to_color(square,(combobuf[l.data[i]].walk&15));
11594 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11595 }
11596 }
11597 destroy_bitmap(square);
11598 }
11599
11600 //putscr
11601 }
11602
11603 void do_bmpdrawlayercflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11604 {
11605 //sdci[1]=layer
11606 //sdci[2]=map
11607 //sdci[3]=screen
11608 //sdci[4]=layer
11609 //sdci[5]=x
11610 //sdci[6]=y
11611 //sdci[7]=rotation
11612 //[8] noclip
11613 //sdci[9]=opacity
11614
11615
11616 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11617 int32_t screen = sdci[3]/10000;
11618 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11619 int32_t x = sdci[5]/10000;
11620 int32_t y = sdci[6]/10000;
11621 int32_t x1 = x + xoffset;
11622 int32_t y1 = y + yoffset;
11623 int32_t rotation = sdci[7]/10000;
11624
11625 byte noclip = (sdci[8]!=0);
11626 int32_t opacity = sdci[9]/10000;
11627
11628 uint32_t index = (uint32_t)map_screen_index(map, screen);
11629 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11630
11631 if(!m) //no need to log it.
11632 return;
11633
11634 if(index >= TheMaps.size())
11635 {
11636 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11637 return;
11638 }
11639
11640 const mapscr & l = *m;
11641
11642 BITMAP* b = bmp;
11643
11644 if(rotation != 0)
11645 b = script_drawing_commands.AquireSubBitmap(256, 176);
11646
11647
11648 const int32_t maxX = isOffScreen ? 512 : 256;
11649 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11650 bool transparent = opacity <= 128;
11651
11652 if(rotation != 0) // rotate
11653 {
11654 draw_map_cflag(b, l, x1, y1);
11655
11656 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11657 script_drawing_commands.ReleaseSubBitmap(b);
11658 }
11659 else
11660 {
11661 BITMAP* square = create_bitmap_ex(8,16,16);
11662 for(int32_t i(0); i < 176; ++i)
11663 {
11664 const int32_t x2 = ((i&15)<<4) + x1;
11665 const int32_t y2 = (i&0xF0) + y1;
11666
11667 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11668 {
11669 clear_to_color(square,l.sflag[i]);
11670 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11671 }
11672 }
11673 destroy_bitmap(square);
11674 }
11675
11676 //putscr
11677 }
11678
11679 void do_bmpdrawlayerctyper(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11680 {
11681 //sdci[1]=layer
11682 //sdci[2]=map
11683 //sdci[3]=screen
11684 //sdci[4]=layer
11685 //sdci[5]=x
11686 //sdci[6]=y
11687 //sdci[7]=rotation
11688 //[8] noclip
11689 //sdci[9]=opacity
11690
11691 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11692 int32_t screen = sdci[3]/10000;
11693 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11694 int32_t x = sdci[5]/10000;
11695 int32_t y = sdci[6]/10000;
11696 int32_t x1 = x + xoffset;
11697 int32_t y1 = y + yoffset;
11698 int32_t rotation = sdci[7]/10000;
11699
11700 byte noclip = (sdci[8]!=0);
11701 int32_t opacity = sdci[9]/10000;
11702 uint32_t index = (uint32_t)map_screen_index(map, screen);
11703 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11704
11705 if(!m) //no need to log it.
11706 return;
11707
11708 if(index >= TheMaps.size())
11709 {
11710 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11711 return;
11712 }
11713
11714 const mapscr & l = *m;
11715
11716 BITMAP* b = bmp;
11717
11718 if(rotation != 0)
11719 b = script_drawing_commands.AquireSubBitmap(256, 176);
11720
11721
11722 const int32_t maxX = isOffScreen ? 512 : 256;
11723 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11724 bool transparent = opacity <= 128;
11725
11726 if(rotation != 0) // rotate
11727 {
11728 draw_map_combotype(b, l, x1, y1);
11729
11730 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11731 script_drawing_commands.ReleaseSubBitmap(b);
11732 }
11733 else
11734 {
11735 BITMAP* square = create_bitmap_ex(8,16,16);
11736 for(int32_t i(0); i < 176; ++i)
11737 {
11738 const int32_t x2 = ((i&15)<<4) + x1;
11739 const int32_t y2 = (i&0xF0) + y1;
11740
11741 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11742 {
11743 clear_to_color(square,(combobuf[l.data[i]].type));
11744 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11745 }
11746 }
11747 destroy_bitmap(square);
11748 }
11749
11750 //putscr
11751 }
11752
11753 void do_bmpdrawlayerciflagr(BITMAP *bmp, int32_t *sdci, int32_t xoffset, int32_t yoffset, bool isOffScreen)
11754 {
11755 //sdci[1]=layer
11756 //sdci[2]=map
11757 //sdci[3]=screen
11758 //sdci[4]=layer
11759 //sdci[5]=x
11760 //sdci[6]=y
11761 //sdci[7]=rotation
11762 //[8] noclip
11763 //sdci[9]=opacity
11764
11765 int32_t map = (sdci[2]/10000)-1; //zscript map indices start at 1.
11766 int32_t screen = sdci[3]/10000;
11767 int32_t sourceLayer = vbound(sdci[4]/10000, 0, 6);
11768 int32_t x = sdci[5]/10000;
11769 int32_t y = sdci[6]/10000;
11770 int32_t x1 = x + xoffset;
11771 int32_t y1 = y + yoffset;
11772 int32_t rotation = sdci[7]/10000;
11773 byte noclip = (sdci[8]!=0);
11774 int32_t opacity = sdci[9]/10000;
11775
11776 uint32_t index = (uint32_t)map_screen_index(map, screen);
11777 const mapscr* m = getmapscreen(map, screen, sourceLayer);
11778
11779 if(!m) //no need to log it.
11780 return;
11781
11782 if(index >= TheMaps.size())
11783 {
11784 al_trace("DrawLayer: invalid map index \"%i\". Map count is %lu.\n", index, TheMaps.size());
11785 return;
11786 }
11787
11788 const mapscr & l = *m;
11789
11790 BITMAP* b = bmp;
11791
11792 if(rotation != 0)
11793 b = script_drawing_commands.AquireSubBitmap(256, 176);
11794
11795
11796 const int32_t maxX = isOffScreen ? 512 : 256;
11797 const int32_t maxY = isOffScreen ? 512 : 176 + yoffset;
11798 bool transparent = opacity <= 128;
11799
11800 if(rotation != 0) // rotate
11801 {
11802 draw_map_comboiflag(b, l, x1, y1);
11803
11804 rotate_sprite(bmp, b, x1, y1, degrees_to_fixed(rotation));
11805 script_drawing_commands.ReleaseSubBitmap(b);
11806 }
11807 else
11808 {
11809 BITMAP* square = create_bitmap_ex(8,16,16);
11810 for(int32_t i(0); i < 176; ++i)
11811 {
11812 const int32_t x2 = ((i&15)<<4) + x1;
11813 const int32_t y2 = (i&0xF0) + y1;
11814
11815 if(noclip&&(x2 > -16 && x2 < maxX && y2 > -16 && y2 < maxY)) //in clipping rect
11816 {
11817 clear_to_color(square,(combobuf[l.data[i]].flag));
11818 blit(square, b, 0, 0, x2, y2, square->w, square->h);
11819 }
11820 }
11821 destroy_bitmap(square);
11822 }
11823
11824 //putscr
11825 }
11826
11827
11828
11829 /////////////////////////////////////////////////////////
11830 // do primitives
11831 ////////////////////////////////////////////////////////
11832
11833 // Draw commands can vary in terms of the origin/coordinate system to draw as. This
11834 // is controlled via `DrawOrigin`. Previous to `DrawOrigin`, this always drew
11835 // relative to the playing field (except for offscreen bitmaps).
11836 417020036 void do_primitives(BITMAP *targetBitmap, int32_t type)
11837 {
11838 417020036 do_primitives(targetBitmap, type, 0, playing_field_offset);
11839 417020036 }
11840
11841 418383484 void do_primitives(BITMAP *targetBitmap, int32_t type, int32_t xoff, int32_t yoff)
11842 {
11843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 418383484 times.
418383484 if(type > 7)
11844 return;
11845
3/4
✓ Branch 0 taken 133613768 times.
✓ Branch 1 taken 284769716 times.
✓ Branch 2 taken 133613768 times.
✗ Branch 3 not taken.
418383484 if(type >= 0 && origin_scr->hidescriptlayers & (1<<type))
11846 return; //Script draws hidden for this layer
11847
2/2
✓ Branch 0 taken 4856981 times.
✓ Branch 1 taken 413526503 times.
418383484 if(!script_drawing_commands.is_dirty(type))
11848 413526503 return; //No draws to this layer
11849
11850 4856981 color_map = trans_table2;
11851 //--script_drawing_commands[][] reference--
11852 //[][0]: type
11853 //[][1-16]: defined by type
11854 //...
11855 //[][DRAWCMD_BMP_TARGET]: bitmap pointer
11856 //[][DRAWCMD_CURRENT_TARGET]: current render target at time command is queued? unused?
11857
11858 4856981 const int32_t type_mul_10000 = type * 10000;
11859 4856981 const int32_t numDrawCommandsToProcess = script_drawing_commands.Count();
11860 4856981 FFCore.numscriptdraws = numDrawCommandsToProcess;
11861
11862
2/2
✓ Branch 0 taken 369787697 times.
✓ Branch 1 taken 4856981 times.
374644678 for (int i = 0; i < numDrawCommandsToProcess; i++)
11863 {
11864 369787697 auto& command = script_drawing_commands[i];
11865 369787697 int32_t *sdci = &script_drawing_commands[i][0];
11866
11867
2/2
✓ Branch 0 taken 246614455 times.
✓ Branch 1 taken 123173242 times.
369787697 if (sdci[1] != type_mul_10000)
11868 246614455 continue;
11869
11870 123173242 DrawOrigin draw_origin = command.draw_origin;
11871
11872 // get the correct render target, if set via Screen->SetRenderTarget
11873 // Note: This is a deprecated feature.
11874 123173242 BITMAP *bmp = zscriptDrawingRenderTarget->GetTargetBitmap(sdci[DRAWCMD_CURRENT_TARGET]);
11875 bool isTargetOffScreenBmp;
11876
11877
2/2
✓ Branch 0 taken 6478283 times.
✓ Branch 1 taken 116694959 times.
123173242 if(!bmp)
11878 {
11879 116694959 bmp = targetBitmap;
11880 116694959 isTargetOffScreenBmp = false;
11881 116694959 }
11882 else
11883 {
11884 // Render target was set to a internal bitmap (but not the screen bitmap).
11885 6478283 isTargetOffScreenBmp = true;
11886 6478283 draw_origin = DrawOrigin::Screen;
11887 }
11888
11889 123173242 current_target_bmp = bmp;
11890
11891 int xoffset, yoffset;
11892
1/2
✓ Branch 0 taken 123173242 times.
✗ Branch 1 not taken.
123173242 if (auto r = get_draw_origin_offset(draw_origin, command.draw_origin_target, xoff, yoff))
11893 {
11894 123173242 std::tie(xoffset, yoffset) = *r;
11895 123173242 }
11896 else
11897 {
11898 continue;
11899 }
11900
11901 123173242 secondary_draw_origin_xoff = 0;
11902 123173242 secondary_draw_origin_yoff = 0;
11903
2/2
✓ Branch 0 taken 121378016 times.
✓ Branch 1 taken 1795226 times.
123173242 if (command.secondary_draw_origin != DrawOrigin::Default)
11904 {
11905
1/2
✓ Branch 0 taken 1795226 times.
✗ Branch 1 not taken.
1795226 if (auto r = get_draw_origin_offset(command.secondary_draw_origin, command.secondary_draw_origin_target, xoff, yoff))
11906 {
11907 1795226 std::tie(secondary_draw_origin_xoff, secondary_draw_origin_yoff) = *r;
11908 1795226 }
11909 else
11910 {
11911 continue;
11912 }
11913 1795226 }
11914
11915
40/87
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 3344855 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1170681 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 1850 times.
✓ Branch 7 taken 2351475 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 404879 times.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
✓ Branch 14 taken 2302534 times.
✗ Branch 15 not taken.
✓ Branch 16 taken 2761920 times.
✗ Branch 17 not taken.
✓ Branch 18 taken 5327982 times.
✓ Branch 19 taken 30256034 times.
✓ Branch 20 taken 964155 times.
✓ Branch 21 taken 176452 times.
✓ Branch 22 taken 1607511 times.
✓ Branch 23 taken 201739 times.
✓ Branch 24 taken 9266 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
✗ Branch 27 not taken.
✓ Branch 28 taken 1080 times.
✓ Branch 29 taken 937483 times.
✗ Branch 30 not taken.
✓ Branch 31 taken 4370235 times.
✓ Branch 32 taken 50406 times.
✓ Branch 33 taken 12431 times.
✗ Branch 34 not taken.
✓ Branch 35 taken 192290 times.
✗ Branch 36 not taken.
✓ Branch 37 taken 502 times.
✓ Branch 38 taken 144 times.
✗ Branch 39 not taken.
✓ Branch 40 taken 80910 times.
✓ Branch 41 taken 64994 times.
✗ Branch 42 not taken.
✓ Branch 43 taken 11288 times.
✗ Branch 44 not taken.
✓ Branch 45 taken 1982263 times.
✓ Branch 46 taken 40175665 times.
✗ Branch 47 not taken.
✗ Branch 48 not taken.
✓ Branch 49 taken 865 times.
✓ Branch 50 taken 45504 times.
✗ Branch 51 not taken.
✗ Branch 52 not taken.
✗ Branch 53 not taken.
✗ Branch 54 not taken.
✗ Branch 55 not taken.
✓ Branch 56 taken 143658 times.
✓ Branch 57 taken 2740 times.
✗ Branch 58 not taken.
✗ Branch 59 not taken.
✓ Branch 60 taken 1024 times.
✗ Branch 61 not taken.
✗ Branch 62 not taken.
✓ Branch 63 taken 2062708 times.
✗ Branch 64 not taken.
✓ Branch 65 taken 113653 times.
✗ Branch 66 not taken.
✗ Branch 67 not taken.
✗ Branch 68 not taken.
✗ Branch 69 not taken.
✗ Branch 70 not taken.
✗ Branch 71 not taken.
✓ Branch 72 taken 2134433 times.
✓ Branch 73 taken 34749 times.
✓ Branch 74 taken 43007 times.
✗ Branch 75 not taken.
✗ Branch 76 not taken.
✗ Branch 77 not taken.
✗ Branch 78 not taken.
✗ Branch 79 not taken.
✓ Branch 80 taken 19821648 times.
✗ Branch 81 not taken.
✓ Branch 82 taken 7323 times.
✗ Branch 83 not taken.
✓ Branch 84 taken 906 times.
✗ Branch 85 not taken.
✗ Branch 86 not taken.
123173242 switch(sdci[0])
11916 {
11917 case RECTR:
11918 {
11919 3344855 do_rectr(bmp, sdci, xoffset, yoffset);
11920 }
11921 3344855 break;
11922 case FRAMER:
11923 {
11924 do_framer(bmp, sdci, xoffset, yoffset);
11925 }
11926 break;
11927
11928
11929 case CIRCLER:
11930 {
11931 1170681 do_circler(bmp, sdci, xoffset, yoffset);
11932 }
11933 1170681 break;
11934
11935 case ARCR:
11936 {
11937 do_arcr(bmp, sdci, xoffset, yoffset);
11938 }
11939 break;
11940
11941 case ELLIPSER:
11942 {
11943 1850 do_ellipser(bmp, sdci, xoffset, yoffset);
11944 }
11945 1850 break;
11946
11947 case LINER:
11948 {
11949 2351475 do_liner(bmp, sdci, xoffset, yoffset);
11950 }
11951 2351475 break;
11952
11953 case SPLINER:
11954 {
11955 do_spliner(bmp, sdci, xoffset, yoffset);
11956 }
11957 break;
11958
11959 case PUTPIXELR:
11960 {
11961 404879 do_putpixelr(bmp, sdci, xoffset, yoffset);
11962 }
11963 404879 break;
11964 case PIXELARRAYR:
11965 {
11966 do_putpixelsr(bmp, i, sdci, xoffset, yoffset);
11967 }
11968 break;
11969
11970 case TILEARRAYR:
11971 {
11972 do_fasttilesr(bmp, i, sdci, xoffset, yoffset);
11973 }
11974 break;
11975
11976 case LINESARRAY:
11977 {
11978 do_linesr(bmp, i, sdci, xoffset, yoffset);
11979 }
11980 break;
11981
11982 case COMBOARRAYR:
11983 {
11984 do_fastcombosr(bmp, i, sdci, xoffset, yoffset);
11985 }
11986 break;
11987
11988
11989
11990 case DRAWTILER:
11991 {
11992 2302534 do_drawtiler(bmp, sdci, xoffset, yoffset);
11993 }
11994 2302534 break;
11995
11996 case DRAWTILECLOAKEDR:
11997 {
11998 do_drawtilecloakedr(bmp, sdci, xoffset, yoffset);
11999 }
12000 break;
12001
12002 case DRAWCOMBOR:
12003 {
12004 2761920 do_drawcombor(bmp, sdci, xoffset, yoffset);
12005 }
12006 2761920 break;
12007
12008 case DRAWCOMBOCLOAKEDR:
12009 {
12010 do_drawcombocloakedr(bmp, sdci, xoffset, yoffset);
12011 }
12012 break;
12013
12014 case FASTTILER:
12015 {
12016 5327982 do_fasttiler(bmp, sdci, xoffset, yoffset);
12017 }
12018 5327982 break;
12019
12020 case FASTCOMBOR:
12021 {
12022 30256034 do_fastcombor(bmp, sdci, xoffset, yoffset);
12023 }
12024 30256034 break;
12025
12026 case DRAWCHARR:
12027 {
12028 964155 do_drawcharr(bmp, sdci, xoffset, yoffset);
12029 }
12030 964155 break;
12031
12032 case DRAWINTR:
12033 {
12034 176452 do_drawintr(bmp, sdci, xoffset, yoffset);
12035 }
12036 176452 break;
12037
12038 case DRAWSTRINGR:
12039 {
12040 1607511 do_drawstringr(bmp, i, sdci, xoffset, yoffset);
12041 }
12042 1607511 break;
12043
12044 case DRAWSTRINGR2:
12045 {
12046 201739 do_drawstringr2(bmp, i, sdci, xoffset, yoffset);
12047 }
12048 201739 break;
12049
12050 case QUADR:
12051 {
12052 9266 do_drawquadr(bmp, sdci, xoffset, yoffset);
12053 }
12054 9266 break;
12055
12056 case QUAD3DR:
12057 {
12058 do_drawquad3dr(bmp, i, sdci, xoffset, yoffset);
12059 }
12060 break;
12061
12062 case TRIANGLER:
12063 {
12064 do_drawtriangler(bmp, sdci, xoffset, yoffset);
12065 }
12066 break;
12067
12068 case TRIANGLE3DR:
12069 {
12070 do_drawtriangle3dr(bmp, i, sdci, xoffset, yoffset);
12071 }
12072 break;
12073
12074 case POLYGONR:
12075 {
12076 1080 do_polygonr(bmp, i, sdci, xoffset, yoffset);
12077 }
12078 1080 break;
12079
12080
12081 case BITMAPR:
12082 {
12083 937483 do_drawbitmapr(bmp, sdci, xoffset, yoffset);
12084 }
12085 937483 break;
12086
12087 case BITMAPEXR:
12088 {
12089 do_drawbitmapexr(bmp, sdci, xoffset, yoffset);
12090 }
12091 break;
12092
12093 case DRAWLAYERR:
12094 {
12095 4370235 do_drawlayerr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp);
12096 }
12097 4370235 break;
12098
12099 case DRAWSCREENR:
12100 {
12101 50406 do_drawscreenr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp);
12102 }
12103 50406 break;
12104
12105 12431 case BMPRECTR: bmp_do_rectr(bmp, sdci, xoffset, yoffset); break;
12106 case BMPFRAMER: bmp_do_framer(bmp, sdci, xoffset, yoffset); break;
12107 192290 case BMPCIRCLER: bmp_do_circler(bmp, sdci, xoffset, yoffset); break;
12108 case BMPARCR: bmp_do_arcr(bmp, sdci, xoffset, yoffset); break;
12109 502 case BMPELLIPSER: bmp_do_ellipser(bmp, sdci, xoffset, yoffset); break;
12110 144 case BMPLINER: bmp_do_liner(bmp, sdci, xoffset, yoffset); break;
12111 case BMPSPLINER: bmp_do_spliner(bmp, sdci, xoffset, yoffset); break;
12112 80910 case BMPPUTPIXELR: bmp_do_putpixelr(bmp, sdci, xoffset, yoffset); break;
12113 64994 case BMPDRAWTILER: bmp_do_drawtiler(bmp, sdci, xoffset, yoffset); break;
12114 case BMPDRAWTILECLOAKEDR: bmp_do_drawtilecloakedr(bmp, sdci, xoffset, yoffset); break;
12115 11288 case BMPDRAWCOMBOR: bmp_do_drawcombor(bmp, sdci, xoffset, yoffset); break;
12116 case BMPDRAWCOMBOCLOAKEDR: bmp_do_drawcombocloakedr(bmp, sdci, xoffset, yoffset); break;
12117 1982263 case BMPFASTTILER: bmp_do_fasttiler(bmp, sdci, xoffset, yoffset); break;
12118 40175665 case BMPFASTCOMBOR: bmp_do_fastcombor(bmp, sdci, xoffset, yoffset); break;
12119 case BMPDRAWCHARR: bmp_do_drawcharr(bmp, sdci, xoffset, yoffset); break;
12120 case BMPDRAWINTR: bmp_do_drawintr(bmp, sdci, xoffset, yoffset); break;
12121 865 case BMPDRAWSTRINGR: bmp_do_drawstringr(bmp, i, sdci, xoffset, yoffset); break;
12122 45504 case BMPDRAWSTRINGR2: bmp_do_drawstringr2(bmp, i, sdci, xoffset, yoffset); break;
12123 case BMPQUADR: bmp_do_drawquadr(bmp, sdci, xoffset, yoffset); break;
12124 case BMPQUAD3DR: bmp_do_drawquad3dr(bmp, i, sdci, xoffset, yoffset); break;
12125 case BMPTRIANGLER: bmp_do_drawtriangler(bmp, sdci, xoffset, yoffset); break;
12126 case BMPTRIANGLE3DR: bmp_do_drawtriangle3dr(bmp, i, sdci, xoffset, yoffset); break;
12127 case BMPPOLYGONR: bmp_do_polygonr(bmp, i, sdci, xoffset, yoffset); break;
12128 143658 case BMPDRAWLAYERR: do_bmpdrawlayerr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12129 2740 case BMPDRAWSCREENR: do_bmpdrawscreenr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12130 case BMPDRAWSCREENSOLIDR: do_bmpdrawscreen_solidmaskr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12131 case BMPDRAWSCREENSOLID2R: do_bmpdrawscreen_solidr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12132 1024 case BMPDRAWSCREENCOMBOFR: do_bmpdrawscreen_cflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12133 case BMPDRAWSCREENCOMBOIR: do_bmpdrawscreen_ciflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12134 case BMPDRAWSCREENCOMBOTR: do_bmpdrawscreen_ctyper(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12135 2062708 case BMPBLIT: bmp_do_drawbitmapexr(bmp, sdci, xoffset, yoffset); break;
12136 case BMPMODE7: bmp_do_mode7r(bmp, sdci, xoffset, yoffset); break;
12137 113653 case BMPBLITTO: bmp_do_blittor(bmp, sdci, xoffset, yoffset); break;
12138 case TILEBLIT: do_tileblit(bmp, sdci, xoffset, yoffset, false, "TileBlit()"); break;
12139 case COMBOBLIT: do_comboblit(bmp, sdci, xoffset, yoffset, false); break;
12140 case BMPTILEBLIT: do_tileblit(bmp, sdci, xoffset, yoffset, true, "TileBlit()"); break;
12141 case BMPCOMBOBLIT: do_comboblit(bmp, sdci, xoffset, yoffset, true); break;
12142 case READBITMAP: bmp_do_readr(bmp, i, sdci, xoffset, yoffset); break;
12143 case WRITEBITMAP: bmp_do_writer(bmp, i, sdci, xoffset, yoffset); break;
12144 2134433 case CLEARBITMAP: bmp_do_clearr(bmp, sdci, xoffset, yoffset); break;
12145 34749 case BITMAPCLEARTOCOLOR: bmp_do_clearcolorr(bmp, sdci, xoffset, yoffset); break;
12146 43007 case REGENERATEBITMAP: bmp_do_regenr(bmp, sdci, xoffset, yoffset); break;
12147
12148 case BMPDRAWLAYERSOLIDR: do_bmpdrawlayersolidmaskr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12149 case BMPDRAWLAYERCFLAGR: do_bmpdrawlayercflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12150 case BMPDRAWLAYERCTYPER: do_bmpdrawlayerctyper(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12151 case BMPDRAWLAYERCIFLAGR: do_bmpdrawlayerciflagr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12152 case BMPDRAWLAYERSOLIDITYR: do_bmpdrawlayersolidityr(bmp, sdci, xoffset, yoffset, isTargetOffScreenBmp); break;
12153 19821648 case BMPWRITETILE: do_bmpwritetile(bmp, sdci, xoffset, yoffset); break;
12154 case BMPDITHER: do_bmpdither(bmp, sdci, xoffset, yoffset); break;
12155 7323 case BMPREPLCOLOR: do_bmpreplcol(bmp, sdci, xoffset, yoffset); break;
12156 case BMPSHIFTCOLOR: do_bmpshiftcol(bmp, sdci, xoffset, yoffset); break;
12157 906 case BMPMASKDRAW: do_bmpmaskdraw(bmp, sdci, xoffset, yoffset); break;
12158 case BMPMASKBLIT: do_bmpmaskblit(bmp, sdci, xoffset, yoffset); break;
12159
12160 // The following are special cases, in that the target bitmap is fixed (darkscr_bmp).
12161
12162 case DRAWLIGHT_CONE:
12163 {
12164 int32_t cx = sdci[2]/10000 + xoffset;
12165 int32_t cy = sdci[3]/10000 + yoffset;
12166 int32_t dir = sdci[4]/10000;
12167 int32_t length = sdci[5];
12168 int32_t transp_rad = sdci[6];
12169 int32_t dith_rad = sdci[7];
12170 int32_t dith_type = sdci[8];
12171 int32_t dith_arg = sdci[9];
12172
12173 if(length >= 0) length /= 10000;
12174 else length = game->get_light_rad()*2;
12175 if(!length) break;
12176 if(dir < 0) break;
12177 else dir = NORMAL_DIR(dir);
12178 if(transp_rad >= 0) transp_rad /= 10000;
12179 if(dith_rad >= 0) dith_rad /= 10000;
12180 if(dith_type >= 0) dith_type /= 10000;
12181 if(dith_arg >= 0) dith_arg /= 10000;
12182
12183 // Undo the inherit offset applied within the function. xoffset/yoffset handles for us here.
12184 cx += viewport.x;
12185 cy += viewport.y;
12186
12187 doDarkroomCone(cx,cy,length,dir,darkscr_bmp,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
12188 }
12189 break;
12190
12191 case DRAWLIGHT_CIRCLE:
12192 case DRAWLIGHT_SQUARE:
12193 {
12194 int32_t cx = sdci[2]/10000 + xoffset;
12195 int32_t cy = sdci[3]/10000 + yoffset;
12196 int32_t radius = sdci[4];
12197 int32_t transp_rad = sdci[5];
12198 int32_t dith_rad = sdci[6];
12199 int32_t dith_type = sdci[7];
12200 int32_t dith_arg = sdci[8];
12201
12202 if(radius >= 0) radius /= 10000;
12203 else radius = game->get_light_rad();
12204 if(!radius) break;
12205 if(transp_rad >= 0) transp_rad /= 10000;
12206 if(dith_rad >= 0) dith_rad /= 10000;
12207 if(dith_type >= 0) dith_type /= 10000;
12208 if(dith_arg >= 0) dith_arg /= 10000;
12209
12210 // Undo the inherit offset applied within the function. xoffset/yoffset handles for us here.
12211 cx += viewport.x;
12212 cy += viewport.y;
12213
12214 if (sdci[0] == DRAWLIGHT_CIRCLE)
12215 doDarkroomCircle(cx,cy,radius,darkscr_bmp,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
12216 else
12217 doDarkroomSquare(cx,cy,radius,darkscr_bmp,nullptr,dith_rad,transp_rad,dith_type,dith_arg);
12218 }
12219 break;
12220 }
12221 123173242 }
12222
12223
12224 4856981 color_map=trans_table;
12225 418383484 }
12226
12227 16850371 void CScriptDrawingCommands::Clear()
12228 {
12229 16850371 scb.update();
12230 16850371 dirty_layers.clear();
12231
2/2
✓ Branch 0 taken 11500792 times.
✓ Branch 1 taken 5349579 times.
16850371 if(commands.empty())
12232 11500792 return;
12233
12234 //only clear what was used.
12235 5349579 memset((void*)&commands[0], 0, count * sizeof(CScriptDrawingCommandVars));
12236 5349579 count = 0;
12237
12238 5349579 draw_container.Clear();
12239 16850371 }
12240 CScriptDrawingCommands* CScriptDrawingCommands::pop_commands()
12241 {
12242 CScriptDrawingCommands* ret = new CScriptDrawingCommands();
12243 if(commands.empty())
12244 return ret;
12245 ret->push_commands(this, false);
12246
12247 memset((void*)&commands[0], 0, count * sizeof(CScriptDrawingCommandVars));
12248 count = 0;
12249
12250 draw_container.Clear();
12251 return ret;
12252 }
12253 void CScriptDrawingCommands::push_commands(CScriptDrawingCommands* other, bool del)
12254 {
12255 commands.insert(commands.end(), other->commands.begin(), other->commands.end());
12256 count += other->count;
12257 if(del) delete other;
12258 }
12259
12260 vector<int> CScriptDrawingCommands::get_dirty_layers_in_range(int min, int max)
12261 {
12262 vector<int> ret;
12263 for(int layer : dirty_layers)
12264 {
12265 if(layer < min) continue;
12266 if(layer > max) break;
12267 ret.push_back(layer);
12268 }
12269 return ret;
12270 }
12271
12272 170431 void do_script_draws(BITMAP *targetBitmap, mapscr* scr, int32_t xoff, int32_t yoff, bool hideLayer7)
12273 {
12274
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170431 times.
170431 if(get_qr(qr_CLASSIC_DRAWING_ORDER))
12275
2/2
✓ Branch 0 taken 168921 times.
✓ Branch 1 taken 1510 times.
171941 if(XOR(scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG))
12276 1510 do_primitives(targetBitmap, 2, xoff, yoff);
12277
2/2
✓ Branch 0 taken 163220 times.
✓ Branch 1 taken 7211 times.
170431 if(XOR(scr->flags7&fLAYER3BG, DMaps[cur_dmap].flags&dmfLAYER3BG))
12278 7211 do_primitives(targetBitmap, 3, xoff, yoff);
12279
1/2
✓ Branch 0 taken 170431 times.
✗ Branch 1 not taken.
170431 if(!get_qr(qr_CLASSIC_DRAWING_ORDER))
12280 if(XOR(scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG))
12281 do_primitives(targetBitmap, 2, xoff, yoff);
12282 170431 do_primitives(targetBitmap, 0, xoff, yoff);
12283 170431 do_primitives(targetBitmap, 1, xoff, yoff);
12284
2/2
✓ Branch 0 taken 1510 times.
✓ Branch 1 taken 168921 times.
170431 if(!XOR(scr->flags7&fLAYER2BG, DMaps[cur_dmap].flags&dmfLAYER2BG))
12285 168921 do_primitives(targetBitmap, 2, xoff, yoff);
12286
2/2
✓ Branch 0 taken 7211 times.
✓ Branch 1 taken 163220 times.
170431 if(!XOR(scr->flags7&fLAYER3BG, DMaps[cur_dmap].flags&dmfLAYER3BG))
12287 163220 do_primitives(targetBitmap, 3, xoff, yoff);
12288 170431 do_primitives(targetBitmap, 4, xoff, yoff);
12289 170431 do_primitives(targetBitmap, 5, xoff, yoff);
12290 170431 do_primitives(targetBitmap, 6, xoff, yoff);
12291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170431 times.
170431 if(!hideLayer7) do_primitives(targetBitmap, 7, xoff, yoff);
12292 170431 }
12293